我正在尝试将分离的xlsx文件合并为一个。我在template.xlsx上有一些图表,上面有一些dummie数据。主要目标是使用“data.xlsx”中的数据并将其存储在template.xlsx上的一个名为“data”的工作表中(其中有很多公式和图表引用了“数据”表)
即使很难,我的php内存也高达256M,内存仍然不足。
我的代码到现在为止如下:
$cacheMethod = \PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3;
$cacheEnabled = \PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
if (!$cacheEnabled) {
echo "### WARNING - Sqlite3 not enabled ###" . PHP_EOL;
}
$objReaderTo = \PHPExcel_IOFactory::createReader(
$this->_getXlsTypeByFilename($fileTo)
);
$objReaderFrom = \PHPExcel_IOFactory::createReader(
$this->_getXlsTypeByFilename($fileFrom)
);
$objReaderTo->setIncludeCharts(true);
$objReaderFrom->setReadDataOnly(true);
$objTo = $objReaderTo->load($fileTo);
echo '<h3>mundo</h3>';
$objFrom = $objReaderFrom->load($fileFrom);
echo '<h3>mundo</h3>';
$sheetIdx = $objTo->getIndex( $objTo->getSheetByName('Exports') );
$objTo->removeSheetByIndex($sheetIdx);
$objTo->addExternalSheet($objFrom->getSheetByName('Exports'));
$objDest = \PHPExcel_IOFactory::createWriter($objTo
, $this->_getXlsTypeByFilename($fileTo)
);
$objDest->setIncludeCharts(true);
$objDest->save($fileTo);