How to download basic excel files. 1. Solve the problem of excessive excel lines downloading. 2. Solve the Problem of garbled characters for downloading Chinese file names in ie. None? Php *** excel file generation operation ** @ authorwesleywu * @ date2013.12.9 * classExcel {private $ limit10000; publicfunctiondownload ($ fileName, $
How to download basic excel files. 1. Solve the problem of excessive excel lines downloading. 2. Solve the Problem of garbled characters for downloading Chinese file names in ie. None? Php/*** excel file generation operation ** @ author wesley wu * @ date 2013.12.9 */class Excel {private $ limit = 10000; public function download ($ fileName, $
How to download basic excel files.
1. Solve the problem of excessive excel lines downloading.
2. Solve the Problem of garbled characters for downloading Chinese file names in ie. <无>
_ Charset ($ fileName); header ("Content-Type: application/vnd. ms-excel; charset = gbk "); header (" Content-Disposition: inline; filename = \"". $ fileName. ". xls \ ""); echo"
\ N
"; Echo" \ n
\ N
\ N "; $ guard = 0; foreach ($ data as $ v) {$ guard ++; if ($ guard = $ this-> limit) {ob_flush (); flush (); $ guard = 0;} echo $ this-> _ addRow ($ this-> _ charset ($ v);} echo"
\ N
\ N
";} Private function _ addRow ($ row) {$ cells =" "; foreach ($ row as $ k => $ v) {$ cells. ="
". $ V ."
\ N ";} return"
\ N ". $ cells ."
\ N ";} private function _ charset ($ data) {if (! $ Data) {return false;} if (is_array ($ data) {foreach ($ data as $ k => $ v) {$ data [$ k] = $ this-> _ charset ($ v);} return $ data;} return iconv ('utf-8', 'gbk ', $ data) ;}}$ excel = new Excel (); $ data = array ('data 1', 'Data 2', 'Data 3 ', 'Data 4', 'Data 5', 'Data 6', 'Data 7'), array ('data 1', 'Data 2', 'Data 3 ', 'Data 4', 'Data 5', 'Data 6', 'Data 7'), array ('data 1', 'Data 2', 'Data 3 ', 'Data 4', 'Data 5', 'Data 6', 'Data 7'), array ('data 1', 'Data 2', 'Data 3 ', 'Data 4', 'Data 5', 'Data 6', 'Data 7'), array ('data 1', 'Data 2 ',' Data 3', 'Data 4', 'Data 5', 'Data 6', 'Data 7'); $ excel-> download ('this is a test ', $ data);?>