How does thinkph output excel. Front-end is Loop output table, name = "list" id = "vo". click the button to output the table to excel. Quick Help
Reply to discussion (solution)
How does thinkphp export data from an excel file to the background? This step is now only available.
Try the 3rd-party class
Http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2009/0114/309.html
What is table data transferred to the backend ~~~~~
Which of the following conditions does your table provide for exporting excel statements to query data based on the same conditions?
This is your third post ....
I am still using this method
If you cannot use it, I can use it for further exploration.
/*** Export data into an excel table * @ param $ data: A two-dimensional array. The structure is like the array found from the database * @ param $ title: the first row title of excel, an array, if it is null, no title * @ param $ filename indicates the downloaded file name * @ examlpe $ stu = M ('user'); $ arr = $ stu-> select (); exportexcel ($ arr, array ('id', 'account', 'password', 'Nickname '), 'File name! '); */Function exportexcel ($ data = array (), $ title = array (), $ filename = 'report') {header ("Content-type: application/octet-stream "); header (" Accept-Ranges: bytes "); header (" Content-type: application/vnd. ms-excel "); header (" Content-Disposition: attachment; filename = ". $ filename. ". xls "); header (" Pragma: no-cache "); header (" Expires: 0 "); // export xls to start if (! Empty ($ title) {foreach ($ title as $ k => $ v) {$ title [$ k] = iconv ("UTF-8", "GB2312 ", $ v) ;}$ title = implode ("\ t", $ title); echo "$ title \ n" ;}if (! Empty ($ data) {foreach ($ data as $ key => $ val) {foreach ($ val as $ ck => $ cv) {$ data [$ key] [$ ck] = iconv ("UTF-8", "GB2312", $ cv );} $ data [$ key] = implode ("\ t", $ data [$ key]);} echo implode ("\ n", $ data );}}
What is table data transferred to the backend ~~~~~
Which of the following conditions does your table provide for exporting excel statements to query data based on the same conditions?
I also thought about this idea, but the data in the table is not an array, and there is a sequence ($ key}, which is not in the background.
This is your third post ....
I am still using this method
If you cannot use it, I can use it for further exploration.
/*** Export data into an excel table * @ param $ data: A two-dimensional array. The structure is like the array found from the database * @ param $ title: the first row title of excel, an array, if it is null, no title * @ param $ filename indicates the downloaded file name * @ examlpe $ stu = M ('user'); $ arr = $ stu-> select (); exportexcel ($ arr, array ('id', 'account', 'password', 'Nickname '), 'File name! '); */Function exportexcel ($ data = array (), $ title = array (), $ filename = 'report') {header ("Content-type: application/octet-stream "); header (" Accept-Ranges: bytes "); header (" Content-type: application/vnd. ms-excel "); header (" Content-Disposition: attachment; filename = ". $ filename. ". xls "); header (" Pragma: no-cache "); header (" Expires: 0 "); // export xls to start if (! Empty ($ title) {foreach ($ title as $ k => $ v) {$ title [$ k] = iconv ("UTF-8", "GB2312 ", $ v) ;}$ title = implode ("\ t", $ title); echo "$ title \ n" ;}if (! Empty ($ data) {foreach ($ data as $ key => $ val) {foreach ($ val as $ ck => $ cv) {$ data [$ key] [$ ck] = iconv ("UTF-8", "GB2312", $ cv );} $ data [$ key] = implode ("\ t", $ data [$ key]);} echo implode ("\ n", $ data );}}
I am using this method. $ date is the data in the table. how can I transmit this array from the foreground to the background?
This is your third post ....
I am still using this method
If you cannot use it, I can use it for further exploration.
/*** Export data into an excel table * @ param $ data: A two-dimensional array. The structure is like the array found from the database * @ param $ title: the first row title of excel, an array, if it is null, no title * @ param $ filename indicates the downloaded file name * @ examlpe $ stu = M ('user'); $ arr = $ stu-> select (); exportexcel ($ arr, array ('id', 'account', 'password', 'Nickname '), 'File name! '); */Function exportexcel ($ data = array (), $ title = array (), $ filename = 'report') {header ("Content-type: application/octet-stream "); header (" Accept-Ranges: bytes "); header (" Content-type: application/vnd. ms-excel "); header (" Content-Disposition: attachment; filename = ". $ filename. ". xls "); header (" Pragma: no-cache "); header (" Expires: 0 "); // export xls to start if (! Empty ($ title) {foreach ($ title as $ k => $ v) {$ title [$ k] = iconv ("UTF-8", "GB2312 ", $ v) ;}$ title = implode ("\ t", $ title); echo "$ title \ n" ;}if (! Empty ($ data) {foreach ($ data as $ key => $ val) {foreach ($ val as $ ck => $ cv) {$ data [$ key] [$ ck] = iconv ("UTF-8", "GB2312", $ cv );} $ data [$ key] = implode ("\ t", $ data [$ key]);} echo implode ("\ n", $ data );}}
This method can be used to export the excel file. The problem is that I will not pass the data in the table to $ data in the background.
Come on
What does "pass data in a table to the background" mean?
U014244418 users are in a hurry. The answer is in front of me, and the landlord cannot use it.
U014244418 users are in a hurry. The answer is in front of me, and the landlord cannot use it.
I went to dinner just now, right away
The data in the table is output to excel, and the exportexcel method is the fourth floor method. Now I want to pass the data in this table to this method. I try to pass the four data records in the past. in the form of input, I can only pass the first value.
Come on
What does "pass data in a table to the background" mean?
I am using your post code. title and filename are okay. The problem is data. transfer the data in the table to the method you wrote in the background, and then write the data as $ data. The problem is that the front-end cannot upload the data.
This is your third post ....
I am still using this method
If you cannot use it, I can use it for further exploration.
/*** Export data into an excel table * @ param $ data: A two-dimensional array. The structure is like the array found from the database * @ param $ title: the first row title of excel, an array, if it is null, no title * @ param $ filename indicates the downloaded file name * @ examlpe $ stu = M ('user'); $ arr = $ stu-> select (); exportexcel ($ arr, array ('id', 'account', 'password', 'Nickname '), 'File name! '); */Function exportexcel ($ data = array (), $ title = array (), $ filename = 'report') {header ("Content-type: application/octet-stream "); header (" Accept-Ranges: bytes "); header (" Content-type: application/vnd. ms-excel "); header (" Content-Disposition: attachment; filename = ". $ filename. ". xls "); header (" Pragma: no-cache "); header (" Expires: 0 "); // export xls to start if (! Empty ($ title) {foreach ($ title as $ k => $ v) {$ title [$ k] = iconv ("UTF-8", "GB2312 ", $ v) ;}$ title = implode ("\ t", $ title); echo "$ title \ n" ;}if (! Empty ($ data) {foreach ($ data as $ key => $ val) {foreach ($ val as $ ck => $ cv) {$ data [$ key] [$ ck] = iconv ("UTF-8", "GB2312", $ cv );} $ data [$ key] = implode ("\ t", $ data [$ key]);} echo implode ("\ n", $ data );}}
Add to favorites. thank you.
The problem is solved, and the problem is queried again in the background, which is really troublesome. But I don't know how to adjust the excel width. some data is too big.
Thank you for your help.