0

Actually I have some amount of data stored in mysql database from my website users. Next I want to export this data for user in excel file and i can export data to excel perfectly, But the problem is with unicode content in mysql database, When i am trying to export unicode content into EXCEL it shows like:

 की इतने लिटर पानी के बाद आप कà¥

I am using headers to export, code is below:

header("Content-Type: application/xls");    
header("Content-Disposition: attachment; filename=$filename.xls");  
header("Pragma: no-cache"); 
header("Expires: 0");

Please help me out to Export unicode content in excel file. Thanks in Advance.

Badrinath
  • 501
  • 5
  • 14
  • Possible duplicate of [Is it possible to force Excel recognize UTF-8 CSV files automatically?](https://stackoverflow.com/questions/6002256/is-it-possible-to-force-excel-recognize-utf-8-csv-files-automatically) – Sakura Kinomoto Feb 14 '18 at 10:16
  • That's not a PHP / MySQL problem, its only a problem with excel opening Unicode files. – Sakura Kinomoto Feb 14 '18 at 10:16
  • @SakuraKinomoto no it's problem with exporting data to excel not with excel. – Badrinath Feb 14 '18 at 10:24
  • @SakuraKinomoto i didn't got the solution from that post – Badrinath Feb 14 '18 at 10:26
  • If you create correctly the CSV file in UTF-8 format and you can check the file are OK on a text editor with unicode support, the problem are on Excel side, not PHP side. – Sakura Kinomoto Feb 14 '18 at 10:26
  • @SakuraKinomoto data cannot export in utf 8 format So how can i export it – Badrinath Feb 15 '18 at 17:35
  • Check this post: https://stackoverflow.com/questions/4348802/how-can-i-output-a-utf-8-csv-in-php-that-excel-will-read-properly/4762708#4762708 for how export CSV file in a proper format for Excel Unicode support – Sakura Kinomoto Feb 16 '18 at 10:06

1 Answers1

0

That looks like "Mojibake" for the Devanagari की इतने लिटर पानी के बाद आप क.

See Trouble with UTF-8 characters; what I see is not what I stored for discussion of the cause of Mojibake.

It may be "double encoding" (also discussed in that link).

The HEX for की in utf8 is E0A495 E0A580; if it is double-encoded, the hex will be C3A0 C2A4 E280A2 C3A0 C2A5 E282AC.

Rick James
  • 135,179
  • 13
  • 127
  • 222