PHPEXCEL sets UTF-8 encoding

I have headers:

            header('Content-Type: text/html; charset=UTF-8');
            header("Content-type: application/octetstream");
            header('Content-Disposition: attachment; filename="export.csv"');

but decoding does not work correctly if I have a word in the database "Pagrindinė"in excel show "PagrindinÄ", what is wrong with my headers?

+5
source share
3 answers

What is wrong with my headlines?

Nothing, your headlines look great.

What is wrong with Excel?

The user who opens the file in Excel must tell Excel that the file is in UTF-8 encoding. Ask this user to contact the software vendor that they use for their support options.

LibreOffice , , CSV Excel, .

Excel .

+3

, .php Unicode (UTF-8). .

, .

0

try it:

 header('Content-Transfer-Encoding: binary');
header("Content-Type: application/octet-stream"); 
header("Content-Transfer-Encoding: binary"); 
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); 
header('Content-Disposition: attachment; filename = "Export '.date("Y-m-d").'.xls"'); 
header('Pragma: no-cache'); 

//these characters will make correct encoding to excel 
echo chr(255).chr(254).iconv("UTF-8", "UTF-16LE//IGNORE", $out); 
0
source

All Articles