Phpexcel because it is a memory processing mechanism, when the number of rows or columns of Excel file memory will be an instant hundreds of m, due to server reasons I can not request more memory, so can only think fundamentally solve or circumvent the problem, For example, after processing an Excel file or one of the sheet pages to free memory and then processing the next, online search a circle, not a detailed complete, ask God to help tune, very look forward to.
Ps:
1. I use the version is 1.76, set the use of files and other parameters, completely does not work;
2. Small files have been transferred
3. Mentioned above, no need to talk about the large memory limit
Process the Excel code as follows: Execute error
Fatal error:using $this When not in object context in E:\wamp\www\uploadify\PHPExcel.php on line 796
function Parse_excel_file ($filename)
{
$php _reader = new phpexcel_reader_excel2007 ();
$php _reader = Phpexcel_iofactory::createreaderforfile ($filename);
$php _excel = $php _reader->load ($filename);
$current _sheet = $php _excel->getsheet (0);
$all _column = $current _sheet->gethighestcolumn ();
$all _row = $current _sheet->gethighestrow ();
$list = Array ();
for ($row _index = 2; $row _index <= $all _row; $row _index++)
{
$row _val = ";
for ($col _index = ' A '; $col _index <= $all _column; $col _index++)
{
$ADDR = $col _index. $row _index;
$cell = $current _sheet->getcell ($addr)->getvalue ();
if ($cell instanceof Phpexcel_richtext)
{
$cell = $cell->__tostring ();
$row _val = $row _val. ',' . $cell;
}
Array_push ($list, $row _val);
}
Phpexcel::D Estroy ();
return $list;
}
The additional code in phpexcel.php is as follows:
Public Function Destroy () {
foreach ($this->_worksheetcollection as $index = + $dummy) {
$this->_worksheetcollection[$index]->destroy ();
$this->_worksheetcollection[$index] = null;
}
}
The additional code in worksheet.php is as follows:
Public Function Destroy () {
foreach ($this->_cellcollection as $index = + $dummy) {
$this->_cellcollection[$index] = null;
}
}
Reply to discussion (solution)
How many strips are exported at once?
The calling method should be: $php _excel->destroy ();
Phpexcel library consumes too much memory when computing all in memory cache
Once Ini_set (' Memory_limit ', ' 1024M '); only 1W data can be exported
Finally we used the CSV streaming file The world is quiet a lot
The calling method should be: $php _excel->destroy ();
Phpexcel library consumes too much memory when computing all in memory cache
Once Ini_set (' Memory_limit ', ' 1024M '); only 1W data can be exported
Finally we used the CSV streaming file The world is quiet a lot
Thank you hint, with your writing does not give an error, but the memory is not destroy success, or in the growth, you say the CSV is not directly exported the plug-in or phpexcel export CSV? I'm here to read