PHP Classes

Excel compatibility

Recommend this page to a friend!

      MS-Excel Stream Handler  >  All threads  >  Excel compatibility  >  (Un) Subscribe thread alerts  
Subject:Excel compatibility
Summary:Excel v11.1.0 (MacX Office 2004) won't accept xls file
Messages:6
Author:Charles Turner
Date:2005-01-07 16:55:11
Update:2005-01-19 01:54:27
 

  1. Excel compatibility   Reply   Report abuse  
Picture of Charles Turner Charles Turner - 2005-01-07 16:55:11
The xls file created by running the sample program 'example_export.php' is not recognized by my Excel as being an xls file.

I must be missing something fundamental.

  2. Re: Excel compatibility   Reply   Report abuse  
Picture of Ignatius Teo Ignatius Teo - 2005-01-08 02:03:19 - In reply to message 1 from Charles Turner
Try the updated release posted yesterday.

  3. Re: Excel compatibility   Reply   Report abuse  
Picture of Charles Turner Charles Turner - 2005-01-15 16:32:39 - In reply to message 2 from Ignatius Teo
Just to be sure I downloaded the package again, and its file date for excel.php is Jan 7, 2005 6:48AM.

My MS Excel still gives this message when I open file example.xls that was created by example_export.php:

"This file is not in a recognizable format."

Excel will then open the file, but the spread sheet displayed is clearly not correct.

My php is 4.3.2.

Maybe I can find a different version of Excel on a different machine to try as a test.




  4. Re: Excel compatibility   Reply   Report abuse  
Picture of Ignatius Teo Ignatius Teo - 2005-01-16 02:33:05 - In reply to message 3 from Charles Turner
Hi Charles, I don't think it is an Excel issue. All versions of Excel *should* be able to read the BIFF8 file format (which this class uses).

I am experiencing the same issue with exactly the same code. It's running perfectly on my WinXP box both at home and work, running Apache 2.0.48/PHP 4.3.6 and on my Linux box running Apache 1.3.29/PHP 4.3.4.

But on the Solaris box at work, running Apache 1.3.29/PHP 4.3.6 it's coming up with exactly the same problem: "Unrecognized format"

Unfortunately I'm not entirely sure what the issue is, since it's working on some boxes and not on others. It's definitely not the version of Excel, coz the same file that gets downloaded is being opened by the same version of Excel. But depending on what box it is being downloaded from, it either opens it fine, or can't recognize the format.

Further investigation is required. It would be helpful if you could make a note of what platform you're running on and what versions of Apache/PHP/Excel you are using.

  5. Re: Excel compatibility   Reply   Report abuse  
Picture of Charles Turner Charles Turner - 2005-01-18 19:02:25 - In reply to message 4 from Ignatius Teo
I think I found the problem. It is an "endian" issue. I backed into this discovery when I noticed that it was the the system where the PHP was executed, not the system where the spreadsheet was later run, that made the difference.

My Mac OSX machine (Power PC processor) is "big-endian." PCs running on descendants of the x86 processor are "little-endian." In the unix world apparently some processors are one way and others are the other way.

In "excel.php" I changed all the pack() functions where the "s" format was used to the "v" format (i.e. specify "little-endian"). That did the trick for me. The example.xls created this way was accepted by my Excel with no complaints.

Here's the www page were I found some discussion of this for pack():
<http://www.phpdig.net/ref/rn45re877.html>


  6. Re: Excel compatibility   Reply   Report abuse  
Picture of Ignatius Teo Ignatius Teo - 2005-01-19 01:54:27 - In reply to message 5 from Charles Turner
Thanks for pointing this out. I'll post an update sometime when I get a chance.