<?php
require '../PHPExcel/PHPExcel.php';
require '../PHPExcel/PHPExcel/IOFactory.php';
$inputFileType = 'Excel2007';
$inputFileName = '../file/example1.xlsx';
$sheetnames = array('Data Sheet #1','Data Sheet #3');
class MyReadFilter implements PHPExcel_Reader_IReadFilter
{
public function readCell($column, $row, $worksheetName = '') {
// Read rows 1 to 7 and columns A to E only
if ($row >= 1 && $row <= 7) {
if (in_array($column,range('A','E'))) {
return true;
}
}
return false;
}
}
/** Create an Instance of our Read Filter **/
$filterSubset = new MyReadFilter();
/** Create a new Reader of the type that has been identified **/
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
/** Tell the Reader that we want to use the Read Filter **/
$objReader->setReadFilter($filterSubset);
/** Load $inputFileName to a PHPExcel Object **/
$objPHPExcel = $objReader->load($inputFileName);
?>