There are many ways to generate Excel that record a relatively simple one in PHP 5.3.8.
1 function Xlsbof () {2 echo Pack ("Ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0), 3 return, 4} 5 function xlseof () {6 EC Ho Pack ("ss", 0x0A, 0x00); 7 return; 8} 9 function Format ($STR) {$STR = Str_replace ("\" "," ", $STR), one-by-one (Strpos ($STR,", ")) {$STR =" \ ". $ST R. " \ "";}14 $STR = Iconv ("Utf-8", "gb2312", $STR); $STR;}17 function Xlswritenumber ($Row, $Col, $Value) {1 8 Echo Pack ("Sssss", 0x203, $Row, $Col, 0x0), Echo Pack ("D", $Value), return;21}22 function Xlswritelabel ($Row , $Col, $Value) {$L = strlen ($Value), Echo Pack ("Ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L); Echo $Value; 26 return;27}28 function Write_excel_line ($hang, $lie, $val) {is_numeric ($val)) {Xlswritenumber ($hang, $lie, $val) ;}else{32 Xlswritelabel ($hang, $lie, $val);}34}35 $mktime = Mktime (); (' content-type:text/html; charset= Utf-8 '), the PNS header ("Pragma:public"), The ("expires:0"), the "Cache-control:must-revalidate, post-cHeck=0, Pre-check=0 "), (" Content-type:application/force-download "), and the header (" content-type:application/ Octet-stream ") (" Content-type:application/download "), the header (" Content-disposition:attachment;filename = $mktime. xls "); (" Content-transfer-encoding:binary "); Cell46/xls Data xlsbof (); Xlswritelabel (0, 0, form At (' cell A1 ')), Xlswritelabel (0, 1, format (' cell B1 ')), Xlswritelabel (0, 2, format (' cell C1 ')); Write_excel_line (1, 0, ' A2 '); Write_excel_line (1, 1, ' B2 '); Write_excel_line (1, 2, ' C2 '); Write_excel_line (2, 0, ' A3 '); Line (2, 1, ' B3 '), Write_excel_line (2, 2, ' C3 '), Write_excel_line (3, 0, ' + '), write_excel_line (3, 1, ' a "); E_excel_line (3, 2, ' a '); xlseof ();