Simple sample code for exporting Word documents and excel workbooks using php

Source: Internet
Author: User
This article mainly introduces the simple sample code for exporting Word documents and excel workbooks in php. if you need some help, please refer to it. Code for generating word:
The code is as follows:
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ('content-type: application/doc ');
Header ('content-Disposition: attachment; filename = "test .doc "');

Generate the excel code:
The code is as follows:
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ("Content-type: application/vnd. ms-excel ");
Header ("Content-Disposition: attachment; filename =" test .xls "');

However, you may also encounter many problems during the import process. for example, if an excel file is exported and an ID card number is exported in a column, you will find that the ID card number is automatically calculated in scientific notation, no matter how you modify this attribute, you cannot meet your requirements. Some people say on the Internet that it is okay to change the attribute of this column to text and then input the column. the actual excel operation is true, but the php program cannot export the column. Some people also say that adding single quotation marks before the ID card number will not work if you have tried it. The problem is solved by adding spaces before the exported ID card number data. spaces are spaces in html code. The problem is solved.

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.