Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF8 problem in CSV export #188

Closed
waister opened this issue Aug 4, 2014 · 19 comments
Closed

UTF8 problem in CSV export #188

waister opened this issue Aug 4, 2014 · 19 comments

Comments

@waister
Copy link

waister commented Aug 4, 2014

When I use "->export('xls')", the result is ok, but if I use "->export('csv')", the UTF8 charcters come with encode problem.
Exemple: Waister Guimarães,"waisters@gmail.com"

@MaatwebsiteSupport
Copy link
Contributor

If it goes right with xls, than it could be an issue with the csv writer of PHPExcel. Did you check their issues and forum for this error?

@waister
Copy link
Author

waister commented Aug 6, 2014

Yes, I did check and foud questions, but just for import behaviour.
I attach two files, one in XLS and other in CSV, same generateds by this code (with ->download('xml') of course):

Excel::create('New file', function($excel) {
$excel->sheet('New sheet', function($sheet) {
$sheet->loadView('test');
});
})->download('csv');

@MaatwebsiteSupport
Copy link
Contributor

Ah you are using a view. Try including <meta charset="UTF-8"> in the head of the view file, that should force the use of UTF-8.

@waister
Copy link
Author

waister commented Aug 6, 2014

Sorry, I forgot to attach files in hte last comment.
I used the view for testing only. Even with the mega tag not work too.

@ahmed4000
Copy link

can any one tell me step by step in exporting laravel excel

On Thu, Aug 7, 2014 at 2:07 AM, Waister Nunes notifications@github.com
wrote:

Sorry, I forgot to attach files in hte last comment.
I used the view for testing only. Even with the mega tag not work too.


Reply to this email directly or view it on GitHub
#188 (comment)
.

@MaatwebsiteSupport
Copy link
Contributor

You can find our extensive documentation at: http://www.maatwebsite.nl/laravel-excel/docs

@waister Are you sure the characters you get from the database (I guess they come from there) are UTF-8 encoded?

@MaatwebsiteSupport
Copy link
Contributor

I tested it again with using , when I open the csv file in a text-editor the characters look fine.

@phdomiciano
Copy link

@Maatwebsite Including worked for me. Thanks!

@zhukangfeng
Copy link

@MaatwebsiteSupport
Is there any way to export the csv file not in UTF-8. Such as Exporting file in SJIS for displaying the Japanese.

@maosanch
Copy link

maosanch commented Oct 9, 2015

Also, you can try utf8_encode(string) before writing to a cell.
However I don{t know if this would work when writing array, model or view

@javedLive
Copy link

Did anyone solve the issue because I'm having problem too..
when I'm trying to export the CSV, it's not what i actually should see, it's showing some kind of japanese while I tried to open with excel?
Is that the problem with excel or something else?

@sachinshelke28
Copy link

Please add the following code before download excel

ob_end_clean(); ob_start();

@manhtlu
Copy link

manhtlu commented Aug 18, 2017

for who still get this problem, try edit config/excel.php : from 'use_bom' => false to 'use_bom' => true

@mca-digital
Copy link

mca-digital commented Mar 19, 2018

@manhtqb Simple and clear, thanks!

@rockdrigo
Copy link

if anyone see this,

I have solved the problem:

I changed the value: 'use_bom'=>false to 'use_bom'=>true

in the 'csv' part of excel.php file in config folder. I wish you success!

@ronnyandre
Copy link

This issue still remains during import of CSV files. I did set use_bom to true, but formatting issues are still appearing.

@iohanBefore
Copy link

i still have the same issue, i changed the value : 'use_bom' to true but when i open de csv file in excel, the econding problem persist.

@GlennM
Copy link
Contributor

GlennM commented Jun 13, 2019

i still have the same issue, i changed the value : 'use_bom' to true but when i open de csv file in excel, the econding problem persist.

You're replying to a very old ticket. Please open a new issue (and fill in the issue template details) if you're experiencing issues on Laravel Excel 3.1 version. Older versions of Laravel Excel are no longer supported. Thanks!

@jame0928
Copy link

jame0928 commented Apr 4, 2020

para quienes aún tienen este problema, intente editar config / excel.php: de 'use_bom' => falsea'use_bom' => true

Me salvaste el dia joven excelente!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests