The concrete implementation method of exporting excel in PHP programming technology

Source: Internet
Author: User
Tags php programming
Some time ago we talked about importing Excel files into a database, and today we're going to look at another common feature of PHPEXECL--exporting Excel. This function has troubled many beginners, so through this study, I believe that the next time you meet this situation, it is very easy to deal with, the following to share the process.

As always, the first step, import phpexcel extension, this article takes TP3.1.3 as an example to introduce, import location such as:

Other versions of the development are deployed according to the documentation. The second step: introduced in the controller, the introduction method is as follows:

Here is the introduction of operations, for reference only, in short, the phpexcel.php and phpexecl directory inside some PHP files. By the way, the column is simply processed to facilitate the next write operation. If it is a Chinese file name, add: $fileName = Iconv ("Utf-8", "gb2312", $fileName), processing the file name to prevent errors.

Step three: Write the data using the methods provided by the Phpexcel class.

The attentive reunion asked: Where did $data come from, here to illustrate, $data is passed through the method parameters.

is a third parameter. Last step: Process the table and download the file.

Now, let's make a formal use of the method we just wrote:

From the foreground template gives a tag href attribute call this method, click on it. The downloaded file is the Excel file we want. So now you know how the concrete is to achieve it, if there are doubts, you can leave a message to consult, we discuss the study together.

This article by the Professional Zhengzhou app development company Brigitte Xuan Science and Technology finishing release, original is not easy, if need reprint please indicate source.

The concrete implementation method of exporting excel in PHP programming technology

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.