Error Reader Excel2007 line 653 foreach ($relsDrawing->Relationship as $ele)

May 16, 2008 at 11:59 AM
Hi, here is my code (it is the typical example code slightly modified):
----------------
    require('PHPExcel/Reader/Excel2007.php');
    require('PHPExcel/Writer/Excel2007.php');

    $objReader = new PHPExcel_Reader_Excel2007();
    $objPHPExcel = $objReader->load("NuevoIntegral.xlsx");
    $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);

    $objWriter->save('Integral2.xlsx');
-----------------
I want to simply read and rewrite ir into another file to test how PHPExcel performs.
I have downloaded the last nightly builds. I have all the necessary php modules loaded.

It fails when loading the document.
    $objPHPExcel = $objReader->load("NuevoIntegral.xlsx");

The error is:
----------------
Warning: Invalid argument supplied for foreach() in C:\AppServ\www\phpexcel4business\PHPExcel\Classes\PHPExcel\Reader\Excel2007.php on line 653
Fatal error: Call to a member function children() on a non-object in C:\AppServ\www\phpexcel4business\PHPExcel\Classes\PHPExcel\Reader\Excel2007.php on line 690
----------------

What's happening?
Line 653 is:
    foreach ($relsDrawing->Relationship as $ele) {

The Excel file was firstly an Excel2003 file. I created a new Excel2007 from scratch, copying only the needed cells from the Excel2003, removing before all the enterprise logo images it had.
This excel has a lot of sheets and formulas. You can download it from here if you can test it to see what is going wrong:
http://www.geocities.com/soymonitus/NuevoIntegral.zip

Thanks and see you!
Coordinator
May 19, 2008 at 6:25 AM
Edited May 19, 2008 at 6:26 AM
Will create a work item for this... 
http://www.codeplex.com/PHPExcel/WorkItem/View.aspx?WorkItemId=6179
May 19, 2008 at 8:49 AM
With the last nightly builds I downloaded the Warning disappeared but NOT the Fatal Error. I keep`on gettin:

Fatal error: Call to a member function children() on a non-object in C:\AppServ\www\phpexcel4business\PHPExcel\Classes\PHPExcel\Reader\Excel2007.php on line 696

This time it is on line 696
Coordinator
May 19, 2008 at 10:49 AM
Is it possible to convert the XLS file using Excel 2007 instead of Excel 2003?
May 19, 2008 at 11:22 AM
Of course it is. But I didn't use Excel 2003 to convert it.

What I did was:
- Open my excel file
- Open a new Excel 2007 empty file
- Copy necessary cells from one workbook to another

It can be opened directly into Excel 2007 and saved as xlsx format but I did the process above to have a "cleaner" version of this workbook, without some cells that contained images and some other unneeded garbage.

Why do you ask it?
Coordinator
May 19, 2008 at 12:48 PM
Because it's actually quite a strange error with Excel 2007. Will download your file mentioned above and see what's wrong...
May 19, 2008 at 2:07 PM
If you find it useful, I have run it with the latest AppServ stable version (2.5.10) with apache 2.2 and PHP 5.2.6

If I use the directly converted 2003 to 2007 file (which I don't trust because I would prefer to create a new file with only the formulas I need and not so many garbage), the script does not throw that error but instead it lasts a lot and gives this error:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\AppServ\www\phpexcel4business\PHPExcel\Classes\PHPExcel\Worksheet.php on line 1621
Coordinator
May 20, 2008 at 6:25 AM
That Worksheet.php error seems to be related to our garbage colelction algorithm. Will see if there's room for improvements.