Export to GitHub

php-excel-reader - issue #123

Some negative numbers read incorrectly


Posted on Jul 17, 2011 by Massive Bear

What steps will reproduce the problem? 1. Read a row from an XLS file containing a number. 2. Echo one of the cells.

What is the expected output? What do you see instead? The number is for example -6504.34. php-excel-reader echoes it as 10731120.61. Some numbers are read correctly but they are smaller (-444.3 is read correct). The formatting of the numbers is General.

I tried reading it with PHPExcel and it read these numbers correctly. But I can't use that library cause the sheet contains 50k+ rows and php-excel-reader is small and fast and efficient.

Can I get a quick fix or something? This is really important.

Comment #1

Posted on Aug 25, 2011 by Quick Wombat

Ditto. Large negative numbers are being returned as large(r) positive values - there appears to be a limit at about -2 million. Have tried the code sample a previous user referenced but it also fails. Have just found out that the original developer/poster of this library no longer supports it and judging by his short reply has no interest in helping. So... are you still having the problem? I am trying some things but if I reveal to my bosses that the code I found to read their excel files is not working I will have to eat some serious crow. Am trying to rewrite the function GetInt4d in hopes of finding solution. Any tips or information is appreciated. THanks, John Marno

Comment #2

Posted on Oct 21, 2011 by Helpful Bird

Comment deleted

Comment #3

Posted on Oct 21, 2011 by Helpful Bird

You may already know that there is a fix for the reading of large negative values on 64-bit systems.

Be aware that there are TWO "GetInt4d" functions which must be updated with the new code: GetInt4d(..) and _GetInt4d(..)

Replace the contents of these two functions with this: // Fix for: 32/64bit architecture code: $_or_24 = ord($data[$pos+3]);

if ($_or_24>=128) $_ord_24 = -abs((256-$_or_24) << 24); else $_ord_24 = ($_or_24&127) << 24;

return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $_ord_24;

Comment #4

Posted on Jan 19, 2015 by Grumpy Lion

Comment deleted

Status: New

Labels:
Type-Defect Priority-Medium