PHPExcel 라이브러리를 사용하여 약 1500 개의 행을 반복하려고합니다. 각 행에는 약 25 개의 열이 있습니다.청크 루프에서 PHPExcel 라이브러리를 사용하여 파일의 끝을 어떻게 결정합니까?
내가 (PHPExcel runs out of 256, 512 and also 1024MB of RAM에서 가져온)이 코드를 사용하고 있습니다 :
/** Create a new Reader of the type defined in $inputFileType **/
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
/** Define how many rows we want to read for each "chunk" **/
$chunkSize = 20;
/** Create a new Instance of our Read Filter **/
$chunkFilter = new chunkReadFilter();
/** Tell the Reader that we want to use the Read Filter that we've Instantiated **/
$objReader->setReadFilter($chunkFilter);
/** Loop to read our worksheet in "chunk size" blocks **/
/** $startRow is set to 2 initially because we always read the headings in row #1 **/
for ($startRow = 2; $startRow <= 65536; $startRow += $chunkSize) {
/** Tell the Read Filter, the limits on which rows we want to read this iteration **/
$chunkFilter->setRows($startRow,$chunkSize);
/** Load only the rows that match our filter from $inputFileName to a PHPExcel Object **/
$objPHPExcel = $objReader->load($inputFileName);
// Do some processing here
// Free up some of the memory
$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);
} 나는 많은 행이 데이터를 처리 할
. 그렇다면
function _emptyRow($row) {
$empty=true;
foreach($row as $r) {
if ($r!='') {
$empty = false;
}
}
return $empty;
}
: 다음 검색 행이 작은 함수를 작성하여 비어있는 경우 나 또한 확인하려고 나는 워크 시트 개체에서 메소드 getHighestRow()를 사용했지만, 그것은 단지
A1
를 반환 유지 _emptyRow() 나는 루프 밖으로break
것입니다. 이 일은 나를 위해 일하지 않았다.
누구나 데이터가있는 모든 레코드 만 검색하는 방법을 제안 할 수 있습니까? 이것을 실행하면 약 1500 개의 행에 데이터가 있지만 시간이 만료되기 전에 약 23000에 도달합니다 (set_time_limit (240) 사용).