thinkph in the end how to output Excel, the younger brother quickly crazy. Front desk is The Loop output table, name = "List" id = "VO". Click the button, how to make it output to excel in the form of a table, crazy. Great God, come and help.
Reply to discussion (solution)
Thinkphp export Excel, how to pass the data in the table to the backstage? It's just this one step now.
Try it with a 3rd party class
Http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2009/0114/309.html
What do you mean by passing the table data to the background ~~~~~
What are your tables based on what conditions output, Excel to query the data according to the same criteria is not OK?
This is your third post ....
I'm still this way.
If you don't have any problems, I can use them to further explore.
/** * Export data to an Excel table * @param $data a two-dimensional array, structured like an array from a database * @param $title the first row header of Excel, an array, and no caption if empty * @param $filename downloaded file name * @examlpe $stu = M (' User '); $arr = select ($stu); Exportexcel ($arr, array (' ID ', ' account ', ' Password ', ' nickname '), ' filename! '); */function Exportexcel ($data =array (), $title =array (), $filename = ' report ') {header ("Content-type:application/octe T-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 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 do you mean by passing the table data to the background ~~~~~
What are your tables based on what conditions output, Excel to query the data according to the same criteria is not OK?
I thought of that, but the data in the table is not an array, and there are sequences ($key} This is not the background.
This is your third post ....
I'm still this way.
If you don't have any problems, I can use them to further explore.
/** * Export data to an Excel table * @param $data a two-dimensional array, structured like an array from a database * @param $title the first row header of Excel, an array, and no caption if empty * @param $filename downloaded file name * @examlpe $stu = M (' User '); $arr = select ($stu); Exportexcel ($arr, array (' ID ', ' account ', ' Password ', ' nickname '), ' filename! '); */function Exportexcel ($data =array (), $title =array (), $filename = ' report ') {header ("Content-type:application/octe T-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 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 just use this method, $date this data is the data in the table, how to pass this array from the foreground to the backstage, it is not
This is your third post ....
I'm still this way.
If you don't have any problems, I can use them to further explore.
/** * Export data to an Excel table * @param $data a two-dimensional array, structured like an array from a database * @param $title the first row header of Excel, an array, and no caption if empty * @param $filename downloaded file name * @examlpe $stu = M (' User '); $arr = select ($stu); Exportexcel ($arr, array (' ID ', ' account ', ' Password ', ' nickname '), ' filename! '); */function Exportexcel ($data =array (), $title =array (), $filename = ' report ') {header ("Content-type:application/octe T-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 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 export Excel, no problem, the problem is that I will not pass the data in the table to the backstage $data
Go on.
"Pass the data in the table to the backstage." What do you mean?
u014244418 users are anxious to die, the answer in the eyes, the landlord can not use
u014244418 users are anxious to die, the answer in the eyes, the landlord can not use
I just had a meal, right now.
The data in the table is output to Excel, where the Exportexcel method is the four-storey method. Now to pass this table of data into this method, I try to pass the four data, in the form of input can only pass the first value.
Go on.
"Pass the data in the table to the backstage." What do you mean?
I just use the code you posted, title and filename are fine. The problem is data, which passes the information in the table to the method you wrote in the background, and then writes the data to $data. The problem is, the reception doesn't pass the data.
This is your third post ....
I'm still this way.
If you don't have any problems, I can use them to further explore.
/** * Export data to an Excel table * @param $data a two-dimensional array, structured like an array from a database * @param $title the first row header of Excel, an array, and no caption if empty * @param $filename downloaded file name * @examlpe $stu = M (' User '); $arr = select ($stu); Exportexcel ($arr, array (' ID ', ' account ', ' Password ', ' nickname '), ' filename! '); */function Exportexcel ($data =array (), $title =array (), $filename = ' report ') {header ("Content-type:application/octe T-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 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); } }
Collection, thank you.
Problem solved, in the background and query again, really troublesome. But don't know how to adjust the width of Excel, some of the data is too large
Thank you for your help.