In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "php export excel format data Chinese garbled how to solve," the explanation content in the article is simple and clear, easy to learn and understand, please follow the small series of ideas slowly in-depth, together to study and learn "php export excel format data Chinese garbled how to solve," it!
Solve two problems:
1. Text data such as ID cards are automatically converted into scientific notation.
2. Chinese garbled code problem
Excel export principles from web pages. When we send this data to the client, we want the client program (browser) to read it in excel format, so set the mime type to: application/vnd.ms-excel. Excel will render the data in the format of each cell when reading the file. If the cell does not have a specified format, excel will render the data in the default format. This gives us room for custom data formats, although we must use formats supported by excel. Here are some common formats:
1) Text: vnd.ms-excel.numberformat:@
2) Date: vnd.ms-excel.numberformat: yy/mm/dd
3) Number: vnd.ms-excel.numberformat:#,##0.00
4) Currency: vnd.ms-excel.numberformat: ¥ #,##0.00
5) Percentage: vnd.ms-excel.numberformat: #0.00%
You can also customize these formats, such as the year you can define as: yy-mm and so on. So knowing these formats, how to add them to the cell? It's simple, we just need to add the style to the corresponding tag pair (i.e. closed tag). For example, add a style to the label pair, as follows: 410522198402161833
Similarly, we can add styles to, and we can also add
< /tr>, add styles; when we add styles to both parent and child tag pairs, which style will the data appear in? After testing, it will be rendered in the style closest to the data.
For example, the style of the ID card column:
echo "".$ printable. "\n";
The copy code is as follows:
$filename=iconv("UTF-8", "GB2312//IGNORE","Member Name.xls");//date('Y-m-d-H-i-s'). ".xls";
header("Content-type:application/vnd.ms-excel");
Header("Accept-Ranges:bytes");
Header("Content-Disposition:attachment;filename=".$ filename); //$filename Exported filename
header("Pragma: no-cache");
header("Expires: 0");
echo '
';
echo "
".iconv(" UTF-8 ", "GB2312//IGNORE"," Member Name "). "
".iconv(" UTF-8 ", "GB2312//IGNORE"," Account "). "
".iconv(" UTF-8 ", "GB2312//IGNORE"," Contact "). "
";
foreach ($list as $v)
{
echo "";
echo "".iconv("UTF-8", "GB2312//IGNORE", $v["user_name"]). "";
echo "".$ v["account_id"]. "";
echo "".iconv("UTF-8", "GB2312//IGNORE", $v["contact_name"]). "";
echo "";
}
echo "";
Thank you for reading, the above is "php export excel format data Chinese garbled how to solve" the content, after the study of this article, I believe we export excel format data php Chinese garbled how to solve this problem has a deeper understanding, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.