Use PHPExcel to export the column chart in the YII2 framework.
Export result:
First, download the PHPExcel plug-in package from the official website. The downloaded folder is as follows:
Put the Classes folder into the public method of the
PHPEXCEL is a php plug-in used to generate excel files. It can easily operate excel data, such as generating excel files and modifying excel Data.
I. PHPEXCEL Introduction
PHPEXCEL provides a series of APIs to parse and generate documents such as
Common Methods in PHPExcel and phpexcel
PHPExcel is a very powerful MS Office Excel file generation class library, when you need to output more complex format data, PHPExcel is a good choice. However, the method is relatively cumbersome. List to
The implementation code that uses Phpexcel to export data in PHP.For those unfamiliar with the Phpexcel class library, you can read the contents of the Phpexcel Chinese help manual, and we can phpexcel the relevant examples in the Quick Development
Unzip the contents of the Classes folder in the package into the Application\libraries\ directory, the directory structure is as follows:--application\libraries\phpexcel.php--application\libraries\phpexcel (folder)Modify the
Encountered in the middle of a problem is submitted to the Chinese file name directly into the header in IE will become garbled, the solution is to urlencode the filename first and then into the header, as follows.
Copy Code code as follows:
No more nonsense, just go to the code.
Copy Code code as follows:
Public Function Export_data ($data = Array ())
{
# code ...
Include_once (app_path. ' tools/phpexcel/classes/phpexcel/writer/iwriter.php ');
Include_once (app_path. '
As a normal programmer, several languages are very normal, I believe that most programmers will also write a few PHP programs, if the Web programmer, PHP must be necessary, even if you do not use it to develop large software projects, but also how
The core code is here.
The code is as follows
Copy Code
Header ("Content-type:application/vnd.ms-excel; Charset=utf-8 ");Header ("Pragma:public");Header ("expires:0");Header ("Cache-control:must-revalidate, Post-check=0,
Write and build operations for Excel:
Copy Code code as follows:
Include ' phpexcel.php ';
Include ' phpexcel/writer/excel2007.php ';
Or include ' phpexcel/writer/excel5.php '; For the output. xls
Include ' phpexcel/iofactory.php
Introduction of Phpexcel
Phpexcel provides a series of APIs to parse and generate documents such as Excel,pdf.
Phpexcel Although powerful, but the use of relatively some of the lock, if you need to output more complex format, is a good choice. Can
Phpexcel Download Address: http://phpexcel.codeplex.com/
Import phpexcel.php or other files
The code is as follows
Copy Code
Require_once ' phpexcel.php '; Require_once ' phpexcel/writer/excel5.php '; For other low
In the Web site will often generate tables, CSV and Excel are commonly used in the report format, CSV relatively simple, if you have questions I will release some examples of CSV, here mainly introduced in PHP to generate and read Excel files.
To
1, Phpexcel Introduction
Phpexcel is a PHP class library that is used to manipulate office Excel documents, based on Microsoft's OPENXML Standard and PHP language. You can use it to read and write spreadsheets in different formats, such as Excel
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.