I'm using PHPExcel to read an xlsx workbook, the following is the code I'm using so far just to set the active sheet
date_default_timezone_set('Europe/London');
set_include_path(get_include_path() . PATH_SEPARATOR . './Classes/');
include 'PHPExcel/IOFactory.php';
$reader = PHPExcel_IOFactory::createReader('Excel2007');
$reader->setReadDataOnly(true);
$xlWB = $reader->load('/' . $target_file);
$xlWB->setActiveSheetIndex(0); //EXCEPTION OCCURS HERE
but I'm getting an exception:
Fatal error: Uncaught exception 'PHPExcel_Exception' with message 'You tried to set a sheet active by the out of bounds index: 0. The actual number of sheets is 0.' in /[my root]/Classes/PHPExcel.php:695 Stack trace: #0 /[my-root]/conversion-demo.php(211): PHPExcel->setActiveSheetIndex(0) #1 {main} thrown in /[my root]/Classes/PHPExcel.php on line 695
The file is an .xlsx file, it does exist (the path is correct) and there are 3 sheets in the file.
Am I doing something fundamentally wrong here?