PHP Simple sample code for exporting Word documents and Excel spreadsheets _php tutorial

Source: Internet
Author: User
To generate the code for Word:
Copy CodeThe 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 "');

to generate the code for Excel:
Copy CodeThe 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 ");

But the process will also encounter a lot of problems, such as export Excel, a column to export the identity card number, open Excel file will find that the ID number automatically adopted scientific counting method, regardless of modifying the column properties, can not achieve their own requirements. Some people on the internet said that the first to change the column properties to text, and then input there is no problem, the actual operation of Excel is true, but the PHP program can not be exported. Some people say, in front of the ID number of the single quotation mark, tried also not, finally in the export of the ID card data with a space problem resolution, space is the HTML code space. Problem solving.

http://www.bkjia.com/PHPjc/736781.html www.bkjia.com true http://www.bkjia.com/PHPjc/736781.html techarticle Generate Word Code: Copy Code as follows: Header ("Content-type:application/octet-stream"), Header ("Accept-ranges:bytes"), Header (' Content-type:application/doc '); Header ( .....

  • 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.