0

I am trying to load excel sheet (generated by other application) using phpexcel library, with following code:

$objReader = new PHPExcel_Reader_Excel2007();
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load('callsheet.xlsx');
$objPHPExcel->setActiveSheetIndex(0);
$dataArray = $objPHPExcel->getActiveSheet()->toArray(null, true,true,true);
var_dump($dataArray);

But I got this error.

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 E:\xampp\htdocs\podioexcel\Classes\PHPExcel.php:688 Stack trace: #0 E:\xampp\htdocs\podioexcel\test.php(18): PHPExcel->setActiveSheetIndex(0) #1 {main} thrown in E:\xampp\htdocs\podioexcel\Classes\PHPExcel.php on line 688

One interesting thing. when I open same excel sheet and just save file without any change. Than this code work fine , but problem is that I,m not going to open file each time before to use it. Can you please help me to fix this issue.

TimeToCode
  • 901
  • 2
  • 16
  • 34
  • My guess would be non-standard namespacing in the file that's generated, which loading and saving in MS Excel fixes... but without more information, such as a sample file, then it can only ever be a guess – Mark Baker Nov 21 '16 at 18:46
  • thanks for reply. Download samle file form following link https://drive.google.com/open?id=0B79S561prrEBUDY1NEhXQ1JySWM – Zohaib Shahzad Nov 22 '16 at 04:40
  • @Mark Baker Can you please look into following discussion going on same issue with Podio team. We have tested and confirmed that there is an issue in PHPExcel File. The objective of sharing this thread is to help PHPExcel Team to fix this issue so that no one else faces the same issue http://stackoverflow.com/questions/40792556/file-downloaded-via-podio-export-api-is-not-readable-through-code – Zohaib Shahzad Dec 08 '16 at 15:56
  • @MarkBaker I have posted this message for you can you please lookup. thanks – Zohaib Shahzad Dec 08 '16 at 15:59

0 Answers0