Read - Write - Read Inconsistency

Topics: User Forum
Oct 31, 2009 at 1:48 AM

PHP 5.2.8, PHPExcel 1.7.0, Vista

Hello,

I load foo.xls, then save it to bar.xls.  Then, I test the highest row and column.  They are not identical.

foo.xls is an extremely simple sample file, no formulas or formatting, with columns A-Z counting from 1 to 50.  Text only.

Here is the PHP code and output:

<?PHP
require_once 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel/IOFactory.php';

//Load foo.xls
$file = "foo.xls";
$objPHPExcel    = new PHPExcel();
$objReader      = PHPExcel_IOFactory::createReader("Excel5");
$objPHPExcel    = $objReader->load($file);

//Echo dimensions
echo
  $objPHPExcel->getActiveSheet()->getHighestColumn()." ".
  $objPHPExcel->getActiveSheet()->getHighestRow();    //Returns: Z 53

//Write foo.xls to bar.xls
$objWriter      = PHPExcel_IOFactory::createWriter($objPHPExcel,"Excel5");
$objWriter->save("bar.xls");

//Load bar.xls
$objPHPExcel    = $objReader->load("../spreadsheets/bar.xls");

//Echo dimensions
echo "<br />".
  $objPHPExcel->getActiveSheet()->getHighestColumn()." ".
  $objPHPExcel->getActiveSheet()->getHighestRow();    //Returns: IU 1

?>
The dimensions of foo.xls  are Z, 53.  The dimensions of bar.xls are IU, 1.  The filesize also jumped from 21k to 39k.

What's going on?

Developer
Oct 31, 2009 at 3:11 AM

This has something to do with the way PHPExcel works with columns. Changes are needed to solve this bug and some other similar bugs having to do with columns.

I have now posted this in the issue tracker so you can track when the problem is fixed. Not sure right now when this can be fixed. It is a bit harder to solve than it may seem.

http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10861

Oct 31, 2009 at 3:42 AM

OK. BTW, I also tested it with a smaller worksheet, only fifteen cells, and the returns were "C 5" and "IU 1".  The consistent return on the re-read may be a clue, hope it helps. 

Thanks!

Coordinator
Oct 31, 2009 at 10:16 AM

IU is definitely an interesting column value A-IV is the range of columns in Excel 5, (1-256). Adjusted to 0-255, that would give IU.