Fatal error: Out of memory (1979711488 allocated) (attempt to allocate 131072 bytes) an error occurred while writing the xlsx file using phpexcel

I have an integrated xlsx file for writing from a database using phpexcel. I want to write 3,00,000 entries in an xlsx file. But this is up to a fatal error: Out of memory (1979711488 allocated) (tried to allocate 131072 bytes)

My PHP Version 5.3.28

I also install php ini and cell cache in my code below

ini_set('max_execution_time',-1);
ini_set('memory_limit', '-1'); 
$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_in_memory_gzip;
$cacheSettings = array( ' memoryCacheSize ' => '-1');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);

I look forward to your reply.

thanks

+4
source share
1 answer

, , PHPExcel, OutOfMemory. script , ( , ).

, , Spout: https://github.com/box/spout. PHPExcel, . , , .

XLSX :

$writer = WriterFactory::create(Type::XLSX);
$writer->openToFile($filePath);

while (...) {
    $writer->addRow($singleRow);
}

$writer->close();
+2

Source: https://habr.com/ru/post/1609748/


All Articles