我有以下代码片段取自http://network.convergenceservices.in/forum/5-components/2191-export-excel-a-new-way.html
function xlsBOF() {
echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
return;
}
function xlsEOF() {
echo pack("ss", 0x0A, 0x00);
return;
}
function xlsWriteNumber($Row, $Col, $Value) {
echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
echo pack("d", $Value);
return;
}
function xlsWriteLabel($Row, $Col, $Value ) {
$L = strlen($Value);
echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
echo $Value;
return;
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=vandetailslist.xls ");
header("Content-Transfer-Encoding: binary");
xlsBOF();
xlsWriteLabel(0,0,"Column 1");
xlsWriteLabel(0,1,"Column 2");
xlsWriteLabel(0,2,"Column 3");
xlsWriteLabel(0,3,"Column 4");
$xlsRow = 1;
foreach($somearray as $value)
{
xlsWriteNumber($xlsRow,0,"{Column Value 1}");
xlsWriteLabel($xlsRow,1,"{Column Value 2}");
xlsWriteLabel($xlsRow,2,"{Column Value 3}");
xlsWriteLabel($xlsRow,3,"{Column Value 4}");
$xlsRow++;
}
xlsEOF();
exit;
问题是我只想在每张纸上添加 10 条记录,如果数据更多,我想添加一张新纸并开始在那里添加行。我无法找到添加新工作表的方法。任何帮助将不胜感激。