0

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);
pnuts
  • 58,317
  • 11
  • 87
  • 139
aemonge
  • 2,289
  • 1
  • 24
  • 26
  • Just how big are these spreadsheets? How much data is in them? – Marc B Oct 22 '13 at 17:57
  • Actually they aren't really big. They have 3 sheets with no more than 16x16 cells. I think the charts aren't being cached, cause when I remove them everything goes sweat. BTW: Thanks Marc – aemonge Oct 23 '13 at 07:24

0 Answers0