I'm trying to merge to separated xlsx files into one. I've got some Charts on template.xlsx and some dummie data on it. The main goal is to use the data in "data.xlsx" and store it in a sheet called "data" over template.xlsx (which has a lot of formulas and charts referring to the sheet "data")
Even tough I've got php memory up to 256M, memory is still insufficient.
My code till now is the following:
$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);