zhmicallef / php-excel-reader

Automatically exported from code.google.com/p/php-excel-reader
0 stars 0 forks source link

Some negative numbers read incorrectly #123

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by endar...@gmail.com on 17 Jul 2011 at 8:39

GoogleCodeExporter commented 9 years ago
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

Original comment by johnma...@gmail.com on 25 Aug 2011 at 6:28

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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;

Original comment by sundquis...@gmail.com on 21 Oct 2011 at 8:51