Export excel Data in php format

Source: Internet
Author: User
Solve two problems: 1. The text data such as ID card is automatically converted into scientific notation. 2. Chinese garbled characters: How excel exports data from a Web page. When we send the data to the client, we want the Client Program (browser) to read it in excel format, so we set the mime type to applicationvnd. ms-exce.

Solve two problems: 1. The text data such as ID card is automatically converted into scientific notation. 2. Chinese garbled characters: How excel exports data from a Web page. When we send the data to the client, we want the Client Program (browser) to read it in excel format, so we set the mime type to application/vnd. ms-exce.

Solve two problems:

1. Text data such as ID cards is automatically converted into scientific notation.

2.Chinese garbled charactersProblems

How excel exports data from a Web page. When we send the data to the client, we want the Client Program (browser) to read it in excel format, so we set the mime type to application/vnd. ms-excel: When an excel file is read, data is displayed in the format of each cell. If the cell does not have a specified format, excel displays the data of the cell in the default format. This provides us with a space for custom data formats. Of course, we must use the formats supported by excel. Common formats are listed below:
1) Text: vnd. ms-excel.numberformat :@
2) Date: vnd. ms-excel.numberformat: yyyy/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%

"

For exampleStyle:

Echo"". $ Printable ."\ N ";

$ 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 the exported file name header ("Pragma: no-cache"); header ("Expires: 0"); echo'     
     
     
  '; Echo"
 
 "; Foreach ($ list as $ v) {echo" 
   
     "; Echo" 
    "; Echo" 
    "; Echo" 
    "; Echo" 
   ";} Echo" 
  
". Iconv (" UTF-8 "," GB2312 // IGNORE "," member name ")." ". Iconv (" UTF-8 "," GB2312 // IGNORE "," account ")." ". Iconv (" UTF-8 "," GB2312 // IGNORE "," Contact ")."
". Iconv (" UTF-8 "," GB2312 // IGNORE ", $ v [" user_name "])."". $ V [" account_id "]."". Iconv (" UTF-8 "," GB2312 // IGNORE ", $ v [" contact_name "])."
";

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.