c959137 / php-excel-reader

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

negate numbers showing incorrectly when created in openoffice or neooffice #28

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create a spreadsheet with negative numbers
-1  -5  -10 -50 -100    -250
2. Save the document as an xls file (97/2000/xp)
3. Read the spreadsheet using php-excell-reader

What is the expected output? 
The data should show 
-1  -5  -10 -50 -100    -250

What do you see instead?
-1  1073741819  1073741814  1073741774  1073741724  1073741574

Please provide any additional information below.

Debugging this shows that we are in 
case SPREADSHEET_EXCEL_READER_TYPE_MULRK:

and that in the call to function  _GetIEEE754($rknum) we fall into the case
($rknum & 0x02) != 0)

Original issue reported on code.google.com by npmar...@gmail.com on 8 Jun 2009 at 6:16

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've got the same problem. I couldn't find out where the problem comes from but 
I
remarked that the sum of my negative number in Excel added to the number 
returned by
php-excel-reader is always the same number.

You can also check it in the above example provided by npmarrin. The sum is 
always
1073741824. I don't know if it can help.

In my example, I have the same number, except that my numbers got a decimal 
part. For
example, I got 10728205.73 instead of 9212.51. The sum gives me 10737418.24 
which is
slightely the same as npmarrin with a comma.

After making few tests, I remarked that the "magic" number 1073741824 
correspond to 2^30.

I think I'm not so far from finding the solution but I can't figure out what it 
is.
Any idea?

Original comment by antoine....@gmail.com on 6 Jul 2009 at 8:14

GoogleCodeExporter commented 9 years ago
I have the same problem.  I am assuming that it is a 64 bit problem.  It worked 
fine 
on my previous 32 bit machine.

Original comment by bowlingb...@gmail.com on 1 Feb 2010 at 12:55

GoogleCodeExporter commented 9 years ago
i have the same problem with excel files created in office 2003.
however the it is working with small negative numbers like -5000, but -6000 is 
not
working.

Original comment by NilsLat...@gmail.com on 3 Feb 2010 at 1:33

GoogleCodeExporter commented 9 years ago
A temp fix is to modify _GetInt4d($data, $pos):

function _GetInt4d($data, $pos) {
    $value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) <<
16) | (ord($data[$pos+3]) << 24);
    if ($value>=4294967294) {
      $value=-2;
    }
    if ($value >= 4000000000 && $value < 4294967294) // Add these lines
    {
      $value = -2 - 4294967294 + $value;
    } // End add lines
    return $value;
  }

This artificially pushes the system to recognize when a negative number above 
-2 has
turned up. However, it limits the maximum integer value to 4000000000 and the 
maximum
negative integer value as well.

Still, it works for now.

Original comment by keanloon...@gmail.com on 18 May 2010 at 8:11

GoogleCodeExporter commented 9 years ago
Can try this fix that was listed here:
http://code.google.com/p/php-excel-reader/issues/detail?id=92

Works for me on a 64 bit Linux machine.

Original comment by keanloon...@gmail.com on 19 Oct 2010 at 9:56

GoogleCodeExporter commented 9 years ago
It did not work for me :(

Original comment by leo...@gmail.com on 21 Oct 2010 at 11:36

GoogleCodeExporter commented 9 years ago
Did you replace _GetInt4D completely? 

Original comment by keanloon...@gmail.com on 21 Oct 2010 at 12:40

GoogleCodeExporter commented 9 years ago
I have an old version (and I don't know if i can update) and there where 2 
GetInt4D and _GetInt4D. Now I updated the _GetInt4D and it works! Thank you 
very much

Original comment by leo...@gmail.com on 21 Oct 2010 at 2:34

GoogleCodeExporter commented 9 years ago
thank you!!! :D

Original comment by cinthiac...@gmail.com on 15 Jan 2013 at 6:28

GoogleCodeExporter commented 9 years ago
Thank you very , It works for me

Original comment by Mai.k...@gmail.com on 9 Oct 2013 at 8:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thank you so much!! T.T 
It works for now~

Original comment by j...@bitts.co.kr on 30 Sep 2014 at 11:42

GoogleCodeExporter commented 9 years ago
Just saved me the time I would have spent to fix this function. Thank you very 
much sir! My hat's off to you.

Original comment by mladjo2...@gmail.com on 14 Aug 2015 at 12:09