This topic is locked
[SOLVED]

 Reason for Import error: Trying to get property of non-object

11/11/2011 3:48:23 PM
PHPRunner General questions
A
acpan author

Hi,
Just want to share the experience of Import function.
Phprunner import function is very userful with the various pre and post events,

which is one of the many reasons why i love it. Only thing is the import class phpexcel

does not provide much meaningful error message when there is an error.
Problem:
Some users including myself during testing of import for phpr 6.0,

encountered error:
"Trying to get property of non-object."
This error does not tell anything specific, so it will be hard to know why.
Solution:
After much trial and error, i found that the file format accepted by PHPExcel import module

is Excel 95 (and CSV)and the uploaded file was EXCEL 2003.
So excel file must be saved as Excel 95 version, else it will give you the above error.
acp

Sergey Kornilov admin 11/11/2011

Confirmed issue with Excel 97-2003 format import. Working on the fix.
PS. Excel 2007 imports fine.

A
acpan author 11/12/2011



Confirmed issue with Excel 97-2003 format import. Working on the fix.
PS. Excel 2007 imports fine.


Thanks Sergey.
I digged into the PHPExcel2007.php and see if i can echo a friendlier error message such as

"Please use Excel 95 format" instead of the frightening "Non-Object" error at line 177 of PHPExcel2007.php
And so i inserted this at line 177:
// @@ ACP insert at Line 77 to resolve non-object error when using Excel 2003 instead of Excel 95

if (strlen($rels) == 0 )

{

// Funny, if disable the echo below, it will work for Excel 2003

// echo "May be wrong format, please use Excel 95.";

//

return false;

}
And strangely, i managed to import the file with Excel 2003 if the echo above was remove and only return false.
Not sure if the above helps.
Rgds

ACP

A
acpan author 11/12/2011

Hi Sergey,
Your import functions is really wonderful as my users need to do a lot of imports.
2 points to add:

  1. Would it be possible to import a zip file for large import?
  2. Would it be possible to do a simple check of the file and show error when file format incorrect, instead of parsing the whole file?
    Thanks.

    acp

Sergey Kornilov admin 11/14/2011

We'll fix this shortly.
Zipping exported file is a good idea. We have added this to requested features list.