We are using
PHP has two main processes for exporting Excel files:
1. Define file name
2. Populate Excel data
These two processes may appear some PHP export Excel garbled problem, below I say the solution:
Resolve file name of PHP export Excel garbled:
Garbled reason: The customer uses the Chinese version of the Windows System platform, and the Windows platform file name encoding gb2312 (GBK), and our web page encoding in order to follow the current trend is generally used utf-8 (internationalization) coding, when we: header (" Content-disposition:inline; Filename= "". $filename. ". xls") will appear garbled, if your Web page encoding is gb2312 that does not have to consider the coding problem.
Workaround: For $filename transcoding, execute: Iconv (' Utf-8 ', "gb2312", $filename). If your environment does not support the ICONV function can be replaced by other functions, as long as the $filename encoding can be converted to GBK on the line.
But this problem will come again, Linux users will appear garbled file name (because the Linux platform file name is not GBK encoding).
In view of this problem I use two ways: first: Give up some customers, after all, Windows system users accounted for the majority. Second: Like Gmail, two download addresses are available. A filename GBK encoded, a filename utf-8 encoded.
Troubleshoot PHP export of Excel data in Excel garbled:
PHP Export Excel garbled reason: page encoding and Excel encoding inconsistent.
WORKAROUND: Since the coding is inconsistent, it is OK to make it consistent. Defines the character set for Excel: Header ("Content-type:application/vnd.ms-excel; Charset=utf-8 "), see Charset=utf-8, let it and your page encoding consistent can solve the problem of data garbled in Excel, this is relatively simple!
http://www.bkjia.com/PHPjc/446093.html www.bkjia.com true http://www.bkjia.com/PHPjc/446093.html techarticle when we use PHP to export Excel files There are two main procedures: 1, the definition of file name 2, populate the Excel data in the two processes may appear some PHP exported Excel garbled problem, the following ...