0
我想有多個CSV文件並將它們添加到主CSV文件中。它在數組中添加額外的csv文件時會引發異常錯誤。PHPexcel 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');
是的。我不認爲CSVs有工作表。 – undefined