从PHPparsing文件Excel

我有一个函数PHPparsing文件Excel,它读取所有的行数,但它不会返回对象中的所有数据。 行数3247,但它只返回1023行。

这下面的parsingfunction:

public function parseEquipement($filePath = null) { set_time_limit(0); $listEquipement = []; $count = 0; $chunkSize = 8192; $objReader = PHPExcel_IOFactory::createReader(PHPExcel_IOFactory::identify($filePath)); $spreadsheetInfo = $objReader->listWorksheetInfo($filePath); $chunkFilter = new \Floose\Parse\ChunkReadFilter(); $objReader->setReadFilter($chunkFilter); $objReader->setReadDataOnly(true); $chunkFilter->setRows(0, 1); $objPHPExcel = $objReader->load($filePath); $totalRows = $spreadsheetInfo[0]['totalRows']; for ($startRow = 1; $startRow <= $totalRows; $startRow += $chunkSize) { $chunkFilter->setRows($startRow, $chunkSize); $objPHPExcel = $objReader->load($filePath); $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, null, true, false); $startIndex = ($startRow == 1) ? $startRow : $startRow - 1; if (!empty($sheetData) && $startRow < $totalRows) { $dataToAnalyse = array_slice($sheetData, $startIndex, $chunkSize); if($dataToAnalyse[0][0]==NULL){ break; } for ($i = 0; $i < $chunkSize; $i++) { if ($dataToAnalyse[$i]['0'] != NULL) { $listEquipement[] = new Article($dataToAnalyse[$i]['0'], '', $dataToAnalyse[$i]['1']); $count++; } } } //echo($totalRows); // is best //echo($count); // is wrong //print_r($listEquipement); $objPHPExcel->disconnectWorksheets(); unset($objPHPExcel, $sheetData); } return $listEquipement; } 

我改变了以下所有的代码,但它不起作用:

 public function parseEquipment($filePath = null) { $objReader = PHPExcel_IOFactory::createReader(PHPExcel_IOFactory::identify($filePath)); $objReader->setReadDataOnly(true); $objPHPExcel = $objReader->load($filePath); $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); for ($row = 2; $row <= $highestRow; $row++){ echo $sheet->getCellByColumnAndRow(3, $row)->getCalculatedValue(); echo $sheet->getCellByColumnAndRow(4, $row)->getCalculatedValue(); echo $sheet->getCellByColumnAndRow(2,$row)->getCalculatedValue(); $listEquipement[] = new Article( $sheet->getCellByColumnAndRow(3, $row)->getCalculatedValue(), $sheet->getCellByColumnAndRow(4, $row)->getCalculatedValue(), $sheet->getCellByColumnAndRow(2, $row)->getCalculatedValue() ); } } 

而当我运行我的代码总是显示内存大小错误知道我的文件的大小是81K,它显示在同一时间的行数。

Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (Tried to allocate 54byte

任何人都可以引导和教我如何做我的代码,或者你可以build议我parsing文件Excel的另一个代码?