Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPEXCEL set UTF-8 encode

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 not work correct if I have word in database "Pagrindinė" in excel show "PagrindinÄ", what is wrong with my headers ?

like image 972
user2287965 Avatar asked Oct 21 '22 11:10

user2287965


1 Answers

What is wrong with my headers ?

Nothing, your headers are looking fine.

What is wrong with Excel?

The user who opens the file in Excel needs to tell Excel that the file is in UTF-8 encoding. Direct that user to contact the vendor of the software it uses for her/his support options.

Users of LibreOffice or a derivate of it do not have that problem btw., so one solution is to tell those to install a suite of such, open the CSV file and save it as Excel file for example.

Or you directly create the Excel file on your server.

like image 105
M8R-1jmw5r Avatar answered Oct 24 '22 03:10

M8R-1jmw5r