01simple-download-xls.php fails on OS X

Topics: Developer Forum, User Forum
Nov 9, 2009 at 8:44 PM

I am using OS X 10.6.1

Apache 2.2.11

PHP 5.3

PHPExcel 1.7.1 (downloaded on 11/9/2009)

When I run this test script an XLS is generated. It will not open with OpenOffice. Excel 2003 says the ile is corrupt and wants to repair. It eventually opens with what appears to be the correct info.

I tried running the Excel 2007 version but I get that ZipArchive error can't be found that so many get. 

When I try14Excel5.php (aside from a bunch of timezone warnings that every example spits out) I get:

Deprecated: Function split() is deprecated in /Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php on line 655

Deprecated: Function split() is deprecated in /Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php on line 655

Warning: fopen(/Users/jorfanak/Sites/phpexcel/Tests/14excel5.xls) [function.fopen]: failed to open stream: Permission denied in/Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Shared/OLE/OLE_Root.php on line 109

Fatal error: Uncaught exception 'Exception' with message 'Can't open /Users/jorfanak/Sites/phpexcel/Tests/14excel5.xls. It may be in use or protected.' in /Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Shared/OLE/OLE_Root.php:111 Stack trace: #0 /Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Writer/Excel5.php(224): PHPExcel_Shared_OLE_PPS_Root->save('/Users/jorfanak...') #1 /Users/jorfanak/Sites/phpexcel/Tests/14excel5.php(35): PHPExcel_Writer_Excel5->save('/Users/jorfanak...') #2 {main} thrown in/Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Shared/OLE/OLE_Root.php on line 111

Developer
Nov 10, 2009 at 1:30 AM
jorfanakis wrote:

When I run this test script an XLS is generated. It will not open with OpenOffice. Excel 2003 says the ile is corrupt and wants to repair. It eventually opens with what appears to be the correct info.

Which test are you running?

 

jorfanakis wrote:

When I try14Excel5.php (aside from a bunch of timezone warnings that every example spits out) I get:

Deprecated: Function split() is deprecated in /Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php on line 655

Deprecated: Function split() is deprecated in /Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php on line 655

Yes, this problem was reported today

http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10910

Try using latest source code tomorrow from here:

http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

 

jorfanakis wrote: 

Warning: fopen(/Users/jorfanak/Sites/phpexcel/Tests/14excel5.xls) [function.fopen]: failed to open stream: Permission denied in/Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Shared/OLE/OLE_Root.php on line 109

Fatal error: Uncaught exception 'Exception' with message 'Can't open /Users/jorfanak/Sites/phpexcel/Tests/14excel5.xls. It may be in use or protected.' in /Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Shared/OLE/OLE_Root.php:111 Stack trace: #0 /Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Writer/Excel5.php(224): PHPExcel_Shared_OLE_PPS_Root->save('/Users/jorfanak...') #1 /Users/jorfanak/Sites/phpexcel/Tests/14excel5.php(35): PHPExcel_Writer_Excel5->save('/Users/jorfanak...') #2 {main} thrown in/Users/jorfanak/Sites/phpexcel/Classes/PHPExcel/Shared/OLE/OLE_Root.php on line 111

The file 14excel5.xls is probably locked if you see this warning message. Try to close the file in OpenOffice.org or Excel and run the test again.

Nov 10, 2009 at 2:52 PM
koyama wrote:
jorfanakis wrote:

When I run this test script an XLS is generated. It will not open with OpenOffice. Excel 2003 says the ile is corrupt and wants to repair. It eventually opens with what appears to be the correct info.

Which test are you running?

 

01simpledownload-xls.php

 

I figured out the problem here. In the middle of the file all the warnings about timezone stuff are inserted into the file. In my php.ini if I set display errors to off it alleviates that problem but I am not sure that really fixes it the right way.

Oddly enough I only setup the php.ini to try to get the zip stuff working. I uncommented extension=php_zip.dll and restarted Apache but I still get an error  about unable to find ZipArchive. Any idea what else I need to do to get that working? I don't see anything related to zip in the php.ini besides this line.

 

Thanks!

JO

Nov 10, 2009 at 3:23 PM

jorfanakis,

 

I'm having the same problem on my Mac OSX running 10.5 with PHP 5.2.5

 

Should we be adding

 

extension=php_zip.so instead of uncommenting extension=php_zip.dll

 

 

Nov 10, 2009 at 3:45 PM

Good question. I realize DLL's are not a *nix thing. I thought maybe that was some generic term for all PHP stuff in the php.ini. I don't see anybody adding extensions via .so after doing a few google searches. I only see mention of it for *nix environments at compile time. It is unclear to me if it has to be "enabled" at that time and can't be later on.

I am using the PHP that came with SL. I did not compile it. Unfortunately I also know so little about it I don't know how to track any of this down. In my phpinfo() there is a section "configure command" that has things like -enable-<various thing> or -with-<various> things. I do not see -enable-zip.


SFDonovan wrote:

jorfanakis,

 

I'm having the same problem on my Mac OSX running 10.5 with PHP 5.2.5

 

Should we be adding

 

extension=php_zip.so instead of uncommenting extension=php_zip.dll

 

 

 

Nov 10, 2009 at 4:29 PM

SFDonovan you may want to give this a try:

I modified the approach based on the discussion on this apple support page: http://discussions.apple.com/thread.jspa?threadID=2174107&tstart=0

1. Download php-5.3 from http://us2.php.net/downloads.php

sudo the following

2. cp pcre.h from php-5.3/ext/pcre/pcrelib to /usr/php/ext/pcre

3. pecl install zip

It says it completes and all one needs to do is add exactly what you suggested to the php.ini. extension=zip.so

It took me a bit to figure out the php.ini setup too. So in case you have not. In /etc/hosts there is php.ini.default. It says to copy that to php.ini and modify that. I also read in a wordpress support page that all those timezone warning can be eliminated if you set the date.timezone line to something meaningful. The example I saw was Europe/Dublin and America/Chicago so I have tried America/Denver. This default ini file does not display errors so you may want to toggle that too.

 

I haven't had a chance to see if any of this works and may not today so I thought I would post what I have done so far in hopes that it may be useful.

Nov 10, 2009 at 7:13 PM

I have been following this site here.

 

http://www.viames.it/mac-os-x.html

 

I made sure this was true in my php.ini file

; Directory in which the loadable extensions (modules) reside.
extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20060613"

Then downloaded zip.so and stuck it in my extension directory. stop start apache then did a php -m in Terminal but it still says zip is not loaded.

Do we need this to work to use PHPExcel at all? What if we just display to the browser instead of saving and downloading later?
Coordinator
Nov 10, 2009 at 10:18 PM

You need the zip extension to work with Excel2007 files (or the new ods reader). It isn't necessary for Excel5

Unfortunately I don't have a Mac for testing

Nov 11, 2009 at 9:45 PM

I finally got around to testing the results from what I posted above. It all seems to work. But this is for SL.

You will have to have the extension=zip.so in the php.ini but I don't think you need to specify the extensions dir as you are doing. That is the directory used already (somehow not sure how that works).

In my phpInfo when all is working I get a section for the zip stuff and it says the php.ini file is the ini file being used. Prior to doing what I mentinoed above by copying and modifying hte ini file it said no ini file was loaded. 

 

I don't recall for sure but I think quite a few of the examples fialed for me (including the HTML example) without the ZipArchive stuff working properly first.