Read only one sheet to Array

Topics: Developer Forum, Project Management Forum, User Forum
Jan 29, 2015 at 9:12 AM
I am using PHPExcel to only read values from excel sheets if i use this code , it works fine without no problem:
function ReadUploadedFile($Uploadedfile,$fileExtension)
    {
            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<=100) {
                        if (in_array($column,range('A','Z'))) {
                            return true;
                        }
                    }
                    return false;
                }
            }
}

        $filterSubset = new MyReadFilter();
        $inputFileType="";

        $inputFileType = 'Excel5';
        $objReader = PHPExcel_IOFactory::createReader($inputFileType);
        $objReader->setReadFilter($filterSubset);
        $objReader->setReadDataOnly(true);
        $objPHPExcel = $objReader->load('myExcelsheet.xls');
        $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$sheetData now is an array and i can use it with no problem.

what if i have many worksheets ,and i need to specify only one , as per documentation from PHPEXCEL , it says to use setLoadSheetsOnly()

i try the code blow but it doesn't work.
$inputFileType = 'Excel2007';   
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadFilter($filterSubset);
$objReader->setReadDataOnly(true);
$objReader->setLoadSheetsOnly("Summary"); //my worksheet name is Summary
$objPHPExcel = $objReader->load('myExcelsheet.xlsx');
so what should i write after the above line to convert this object to Array i try this
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
but it gives this error
Call to a member function cellExists() on a non-object
and when i try this
$sheetData = $objPHPExcel->toArray(null,true,true,true);
Call to undefined method PHPExcel::toArray()