我想拥有多个 csv 并将它们添加到主 csv 文件中。当我在数组中添加一个额外的 csv 文件时,它会引发异常错误。
Uncaught exception 'Exception' with message 'Workbook already contains a worksheet named 'Worksheet'. Rename the external sheet first.' in
请在我的代码下面找到
include'../Classes/PHPExcel.php';
include'../Classes/PHPExcel/IOFactory.php';
$filenames = array('Sheet1.csv','Sheet2.csv');
$bigExcel = new PHPExcel();
$bigExcel->removeSheetByIndex(0);
$reader = new PHPExcel_Reader_CSV();
foreach ($filenames as $filename) {
$excel = $reader->load($filename);
foreach ($excel->getAllSheets() as $sheet) {
$bigExcel->addExternalSheet($sheet);
}
foreach ($excel->getNamedRanges() as $namedRange) {
$bigExcel->addNamedRange($namedRange);
}
}
$writer = new PHPExcel_Writer_CSV($bigExcel);
$writer->save('2007-write.csv');