Use a third-party class library PHPExcel in thinkphp to operate Excel files

Source: Internet
Author: User
Recently, I was working on a school project. the project had a requirement to dynamically retrieve data from the database to generate Excel documents in the corresponding format, for this reason, I went to the Internet to search for the corresponding PHP EXcel document code or class library, and found that PHPExcel is an Excel operation written by a foreign organization.

Recently, I was working on a school project. the project had a requirement to dynamically retrieve data from the database to generate Excel documents in the corresponding format, for this reason, I went to the Internet to search for the corresponding PHP EXcel document code or class libraries. I found that the third-party class libraries used to operate Excel documents written by PHPExcel are powerful and easy to use, however, there are two problems:

First, the instruction documents for this class library are all in English.

Second, the case that PHPExcel is used in the thinkphp framework cannot be found on the Internet.

What should I do? Don't think about it.

Because the usage of the class library is basically the same, it is nothing more than importing it into the class to be used.

After importing, you can use the features encapsulated in it. For more information, see http://baike.baidu.com/view/3462519.htm.

The following describes how to import PHPExcel in thinkphp.

Step 1Download the PHP Excel class library package online. decompress the package and you will see the subdirectory:

Open the Classes directory and you will see a PHPExcel. php file. rename this file PHPExcel. class. php.

Step 2Put the entire directory under the ORG directory of the project. the directory structure is as follows:

Step 3Import the PHPExcel class in Action using the import method of thinkphp

Import ('@. ORG. PHPExcel. Classes. PHPExcel'); in this way, you can use the Excel document operations method provided by the PHP Excel class library.

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.