PHPExcel Reader Example #10
Simple File Reader Using a Configurable Read Filter
_startRow = $startRow;
$this->_endRow = $endRow;
$this->_columns = $columns;
}
public function readCell($column, $row, $worksheetName = '') {
if ($row >= $this->_startRow && $row <= $this->_endRow) {
if (in_array($column,$this->_columns)) {
return true;
}
}
return false;
}
}
$filterSubset = new MyReadFilter(9,15,range('G','K'));
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'
';
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
echo 'Loading Sheet "',$sheetname,'" only
';
$objReader->setLoadSheetsOnly($sheetname);
echo 'Loading Sheet using configurable filter
';
$objReader->setReadFilter($filterSubset);
$objPHPExcel = $objReader->load($inputFileName);
echo '
';
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
var_dump($sheetData);
?>