Use php to generate an excel file

Source: Internet
Author: User
Tags ziparchive
Use php to generate an excel file 1. use php to generate an excel file to describe its principles:

The document directory components in excel2007 are:

3. the code is as follows:

 Open ('. /01.xlsx ', ZIPARCHIVE: CREATE); // 3. create an excel file (file directory and xml file) $ ex-> addFromString ('[Content_Types]. XML ',"
 "); $ Ex-> addFromString ('_ rels/. rels ',"
 "); $ Ex-> addFromString ('docprops/app. XML ',"
 "); $ Ex-> addFromString ('docprops/core. XML ',"
 "); $ Ex-> addFromString ('docprops/M. XML ',"
 "); $ Ex-> addFromString ('XL/_ rels/workbork. xml. rels ',"
 "); $ Ex-> addFromString ('XL/theme/theme1.xml ',"
 "); $ Ex-> addFromString ('XL/theme/worksheets/sheet1.xml ',"
 "); $ Ex-> addFromString ('XL/theme/worksheets/sheet2.xml ',"
 "); $ Ex-> addFromString ('XL/theme/worksheets/sheet3.xml ',"
 "); $ Ex-> addFromString ('XL/styles. XML ',"
 "); $ Ex-> addFromString ('XL/workbook. XML ',"
 ");?>

After php is executed, an excel2007 file is generated. after renaming and compressing the file, you can see the generated file. However, the excel file of this version is incomplete and cannot be used, you also need to use an excel package to write a large amount of data. This is only an understanding of ecxcel file generation.

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.