Problems reading Excel 2003 protected file

Topics: User Forum
Aug 1, 2008 at 10:44 AM
Edited Aug 1, 2008 at 11:50 AM
Hi everyone.

My name is Francisco and I have a strange problem using the 'PHPExcel' libraries. 

This is my code:

   include 'PHPExcel/Reader/Excel5.php';
    . . .
    $objReader = new PHPExcel_Reader_Excel5();
    $objPHPExcel = $objReader->load($dir);
    $objPHPExcel->setActiveSheetIndex(3); <--
    $status_tipo = $objPHPExcel->getActiveSheet()->getCell("B6")->getValue();
    $status_desc = $objPHPExcel->getActiveSheet()->getCell("C6")->getValue();

The problem is in the selected line. I have a document with 4 sheets. But I can´t read the last one. I don't know why. It is a sheet with a summary of the previous sheets. I have this code inside of a 'while' loop. The error message is: 

Fatal error: Uncaught exception 'Exception' with message 'Active sheet index is out of bounds.' in D:\OCS Inventory NG\xampp\htdocs\eP01\PHPExcel.php:291 Stack trace: #0 D:\OCS Inventory NG\xampp\htdocs\eP01\indexFRAN.php(51): PHPExcel->setActiveSheetIndex(3) #1 {main} thrown in D:\OCS Inventory NG\xampp\htdocs\eP01\PHPExcel.php on line 291


I can't understand why the active sheet is out of bound.

I have to say that I work with files that have macro and diferent levels of permissions.

¿Can anyone help me?
Aug 1, 2008 at 11:02 AM
Since I am not an expert I have no idea what the problem might be. But can you please try to cut down the Excel file to the most simple file still showing the error (possibly removing macros). Then post the bug in the "Issue Tracker" together with an upload of the file.
Aug 1, 2008 at 11:37 AM
I'm so sorry. I can't do that due to its a document of my company and I don't have the permissions to edit it (and it is prohibited upload out of the intranet too).

I firmly suspect about the macros and permissions. But I don´t understand why if i have the permissions to see the document and the sheet I can´t read the last one.

¿Nobody have the similar error?
Jul 17, 2009 at 7:11 PM

Hi scholar, are you creating a new sheet( $objPHPExcel->createSheet(); ) each time you loop through and want to select a new one?