You can consider adding a character set to the header header("Content-type:application/vnd.ms-excel;charset=UTF-8"); Question: This only tells the browser what character set to choose for viewing. In the end, my requirement is to generate an xls file. Some friends suggest using iconv to transcode.
Question: In this way, the Chinese character encoding in the file is GB18030, but How does Excel know which encoding to use to open it? It can only rely entirely on the OS default. But if you do this when encountering Traditional BIG5, the code will still be garbled. Finally, adopt the approach of phpMyAdmin and use HTMLExcel.
In this way, you can echo directly, There is no need for iconv transcoding, as long as the Content-type in HTML is set (UTF-8 is used here), of course the header still needs to be added:
That's it That's it. Friends who are interested, please test it quickly and see if there is no longer a problem of garbled characters when exporting Chinese content to Excel? ! |