Page 1 of 1
Excel Reader using "Spreadsheet_Excel_Reader class"
Posted: Mon Feb 09, 2009 3:31 am
by vmmene
I using this Spreadsheet_Excel_Reader class to read the excel file. while reading the class i am getting the following error.
Notice: Undefined property: OLERead::$wrkbook in C:\wamp\www\test\excel_reader\oleread.inc.php on line 224
Notice: Undefined index: in C:\wamp\www\test\excel_reader\oleread.inc.php on line 224
If i opened the excel file and save as in excel with different name i am able to read. help me on this ..
thanks in advance.
Re: Excel Reader using "Spreadsheet_Excel_Reader class"
Posted: Mon Feb 09, 2009 6:06 am
by Rovas
The problem you are having is that you didn' t give correctly which workbook or to be specific to read. Read the documentation, if any, better.
I suggest that you use
this class. It uses the newest version, it has lots of documentation and examples. Plus it is supported by Microsoft.
Re: Excel Reader using "Spreadsheet_Excel_Reader class"
Posted: Mon Feb 09, 2009 6:33 am
by Mark Baker
Rovas wrote:I suggest that you use
this class. It uses the newest version, it has lots of documentation and examples. Plus it is supported by Microsoft.
Thanks for the comments Rovas.
Just one minor correction: Despite being hosted on Microsoft's Codeplex OS development site, PHPExcel isn't actively supported by Microsoft, but is a truly independent project; although Microsoft's Open Source team are showing a great deal of interest in our development at the moment.
Re: Excel Reader using "Spreadsheet_Excel_Reader class"
Posted: Mon Jun 08, 2009 12:58 pm
by CoRpO
I've been running into the same troubles ... saving the file let it be parsed
I've found the fix. After digging for hours in the BIFF8 documentation, I've found that earlier versions of Excel 2003 seems to produce incorrect files.
Datas in xls files are stored in chunks of 8224 bytes max. When this limit is reached, a continue OpCode (0x003C) is issued, along with the size of the next chunk.
What was hapenning is my last record of the chunk had Rich attributes On (X*4 bytes after it). What did the faulty excel was to cut the record after it's data and before the Rich attributes, totally screwing the lib which assumes that data and attributes are always next each others.
As I said earlier, here's the fix:
Open
reader.php, near line
472, find this and add the lines shown
Code: Select all
$uniqueStrings = $this->_GetInt4d($this->data, $spos+4);
$spos += 8;
for ($i = 0; $i < $uniqueStrings; $i++) {
// Special case of buggy excel 2003: Continue Opcode between string & richData
if ($spos > $limitpos) { // Add this line
$tmp_offset=$spos-$limitpos; // Add this line
$spos=$limitpos; // Add this line
} else { // Add this line
$tmp_offset=0; // Add this line
} // Add this line
// Read in the number of characters
if ($spos == $limitpos) {
$opcode = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
$conlength = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
if ($opcode != 0x3c) {
return -1;
}
$spos += 4;
$limitpos = $spos + $conlength;
$spos += $tmp_offset; // Add this line
}
This simply adds the offset of the Rich attributes to the begining of the new chunk.
Hope this helps.