Download phpexcelFirst, Baidu search into the official website downloadImport require (dirname (__file__). '/phpexcel/classes/phpexcel.php '); Code:Creating objects$excel =New Phpexcel ();Excel table format, 8 columns$letter =Array' A ',' B ',' C '
Solve 2 problems:1. Text data such as identity cards are automatically converted to scientific notation.
2. The problem of Chinese garbled characters
How Excel exports from a Web page. When we send this data to the client, we want to have the
Using PHP to export MySQL database for Excel table Many ways, the simplest directly using the PHP fputcsv function, there is a direct input CSV format is also possible, to generate Excel standard format we need to use a third-party plug-in
Method
Because the work needs today we want to export the data inside the MySQL database into Execel, and later found on the internet so simple, because the CSV file as long as the "," separate is OK, below we will take a look at the example bar.
Ec (2); & nbsp; when creating a website, you may frequently retrieve data lists. Users usually want to download the list data and store it on the client. Of course, a fixed format is required for downloading the data so that it can be viewed in
Php exports csv or xls file programs. Due to work requirements, we need to export the data in the mysql database to execel for use today, and then I found it on the Internet that it was so simple, because as long as the csv file is used, it is OK to
Command line Export database:
1. Go to the Bin folder in the MySQL directory: cd MySQL to the Bin folder directory
As I entered the command line: CD C:\Program files\mysql\mysql Server 4.1\bin
2, Export database: Mysqldump-
Php exports mysql data to generate a. SQL file. Php Tutorial export mysql tutorial data table data generation. SQL file $ database; database tutorial name $ optionsarray (hostname, IP address charsetutf8, encoding filename $ php Tutorial export
!--? php
//Note include the correct classpath
requ Ire_once (DirName (__file__). '/export.php ');
$exceler = Newjason_excel_export ();
//Generate Excel format here different formats are generated
Phpexcel is a fairly powerful MS Office Excel document Generation Library, and Phpexcel is a good choice when it comes to outputting more complex format data. However, the use of the method is relatively cumbersome. List it in mind.
CSV file Comma Separator value (comma separated value). Intermediate files commonly used for data conversion exist, such as exporting data from MySQL to CSV and importing CSV into SQL Server.CSV file Comma Separator Value (comma separated value).
PHP exports a CSV abstract class. The total number of records and the number of records per batch are calculated and exported cyclically. Avoid insufficient memory.
Php exports a CSV abstract class. The total number of records and the number of
Load Phpexcel class
Require './phpexcel/phpexcel.php ';
Create an instance of an Excel object
$objPHPExcel = new Phpexcel ();
Set document basic Properties
$objProps = $objPHPExcel->getproperties ();
Export data to Excel, welcome to make Bricks
/**
* Exported to Excel file (generally exported in Chinese will be garbled, need to encode conversion)
* Use the following method
* $excel = new Excel ();
* $excel->
Post Code First:
Public Function Check_daochu ($data) {$this->load->library (' Phpexcel '); $this->load->library (' phpexcel/iofactory '); $objPHPExcel = new Phpexcel (); $objWriter = new phpexcel_writer_excel2007
Why did I run the above code will not download??
Reply to discussion (solution)
Something's missing, size and something,
Header ("Content-type:application/octet-stream"); Header ("Accept-ranges:bytes"); Header
The first diagram above is the export, the second is the actual data of the database, the careful buddies found that the exported figure three all changed to 0, this god horse situation AH
Ask the great God for guidance
The code is as follows:
!-
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.