Questions about PHP Excel
Excel templates
A B C D
1 Name Sex Age entry Time
2
3
..
There are table people fields in SQL Name/sex/age/time
Can the contents of the SQL table be written to Excel based on the results of my query in the PHP language?
Like in PHP with tabular $row[] output similar to the results
What do you need to learn? Are there some more detailed examples?
------Solution--------------------
Why bother so much? Using headers to set the header information can be achieved simple Excel. Look at the first method in the connection I sent.
------Solution--------------------
Top, write the CSV format on the line, Jordan is actually the CSV format.
PHP Code
------Solution--------------------
Your way is too troublesome, and the difficulty of maintenance is too big.
Recommend me a common method, using the header to achieve
Start with the report style you need to export, create a new Excel, save it, save it in XML 2003 format, save it, open it with Notepad, and then organize the data in the same way you organize the page.
Then use the following code:
PHP code
header ("Content-type:application/vnd.ms-excel"); Header ("content-disposition:attachment; Filename= $filename "); Echo $excel _content;
------Solution--------------------
1: First comment out the header section, output to the page to see if it is normal.
2: Delete those HTML tags in your code.
------Solution--------------------
To change the encoding when you view Excel.
------Solution--------------------
Explore
This is not difficult, phpexcel this class can help you do it.
Official Online example