Questions about phpexcel excel template & nbsp; ABCD & nbsp; 1 name gender age admission time 23 .. can I use the php language to write the content in the SQL table to excel based on my query results when the table people Field namesexagetime is in SQL? Just like the question about php excel through table $ ro in php
Excel template
A B C D
1 Name gender age admission time
2
3
..
The "people" field in SQL is name/sex/age/time.
Can I use php to write the SQL table content to excel based on my query results?
The output result is similar to that in php through the table $ row [].
What do you need to learn? Are there some detailed examples?
------ Solution --------------------
Why bother. You can set the header information with the header to implement simple excel. Check the first method in the connection I sent.
------ Solution --------------------
At the top, write the csv format. jordan is actually in the csv format.
PHP code
------ Solution --------------------
That method is too troublesome and difficult to maintain.
We recommend that you use the header to implement a common method.
First, create an excel file according to the report style you want to export and save it. save it in xml 2003 format. after saving it, open it in Notepad, then, organize the data like organizing webpages.
Use the following code:
PHP code
Header ("Content-type: application/vnd. ms-excel"); header ("Content-Disposition: attachment; filename = $ filename"); echo $ excel_content;
------ Solution --------------------
1: comment out the header and output it to the page to check whether it is normal.
2: delete the html tags in the code.
------ Solution --------------------
Edit the encoding when viewing the excel file.
------ Solution --------------------
Discussion
This is not difficult. the phpexcel class can help you.
Examples on the official website