PHPExcel cannot read excel sheet

Topics: Developer Forum, User Forum
Sep 30, 2013 at 10:39 AM
I have following code that reads excel 97-2003 file, however, when it runs to $objPHPExcel->setActiveSheetIndex(0); It throws PHPExcel_Exception: You tried to set a sheet active by the out of bounds index: 0. The actual number of sheets is 0. If I change createReader('Excel2007'); to createReader('Excel2003XML'), then it will stuck in $objPHPExcel = $objReader->load("Payment.xls"); So why the actual number of sheet is 0. Please help. Thanks


/* Error reporting /
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

require_once 'Classes/PHPExcel.php';
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load("Payment.xls");
$objWorksheet = $objPHPExcel->getActiveSheet();
Sep 30, 2013 at 10:58 AM
Try automatic mode for loading :

$objPHPExcel = PHPExcel_IOFactory::load("payment.xls");
Sep 30, 2013 at 12:12 PM
Thanks LWol. I tried that. But it stucks in:
$objPHPExcel = PHPExcel_IOFactory::load("payment.xls");

And I find it really stucks in this Excel5.php

if (isset($top->colorIndex)) { $borderTopColor = self::_readColor($top->colorIndex,$this->_palette,$this->_version);
So please help.
Oct 1, 2013 at 11:33 AM
A priori, something in formatting is an issue for PHPExcel.
But in your first example, this is not useful for you.
Try this variant:
$objReader = PHPExcel_IOFactory::createReader ('Excel5');
$objReader->setReadDataOnly (true);
$objPHPExcel = $objReader->load('payment.xls);