Home>Article>Backend Development> What should I do if php exports mysql to excel with garbled characters?

What should I do if php exports mysql to excel with garbled characters?

藏色散人
藏色散人 Original
2020-08-31 10:08:50 2589browse

The solution for php to export mysql to excel with garbled characters: first set the time zone and header information; then clear the buffer through "ob_end_clean();"; then set the table information; finally query the content and export the database data.

What should I do if php exports mysql to excel with garbled characters?

Recommended: "PHP Video Tutorial"

PHP query database export excel and solve the garbled problem, Native code does not require plug-ins

I recently wrote an information system and needed to export the contents of the database to excel

I will post my code below, no phpexcel plug-in is required

System requirements: php5.6

This line of code was not added at the beginning, resulting in garbled output. Just clear the buffer before each data generation,

ob_end_clean();//清除缓冲区,避免乱码

The above is the detailed content of What should I do if php exports mysql to excel with garbled characters?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn