Generated Excel Files have errors

Topics: User Forum
Oct 14, 2009 at 8:58 AM

Hello,

on my system ( php 5.2.4 ) all my generated excel files( excel5 ) have errors and can't be opened with excel 2003.
Even the examples are not working on my system...

What can I check to solve this problem?

Thanks for your Help,

Urkman

Developer
Oct 14, 2009 at 9:06 AM

Are you opening the files on Windows 7? Then that could be the problem.

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

Try upgrading to latest source code:

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

Oct 14, 2009 at 9:14 AM

Hello,

thanks for your answer.

I'm opening the files on a Window XP SP2 Box.

Files generated on my Development Box( Window XP SP2 ) with php 5.2.9 are working fine.

Files generated on my Testing Box( Ubuntu 8.04 ) with php 5.2.4 are not working.

On both Boxes I use the same code with phpExcel Version 1.7.0

Thanks and Greetings,

Urkman

 

Developer
Oct 14, 2009 at 9:30 AM

>> Files generated on my Development Box( Window XP SP2 ) with php 5.2.9 are working fine.

>> Files generated on my Testing Box( Ubuntu 8.04 ) with php 5.2.4 are not working.

You are using identical code to create xls files on those two systems? One is corrupt and the other is not, right?

Can you create two simple xls files by running the same script on those two platforms. Upload the files here with one corrupt file and one not corrupt. I will check in a hex editor what the difference is. It should reveal something. Right now I have no idea what the problem is.

Oct 14, 2009 at 9:34 AM

Hello,

I just changed this two lines in the 01simple.php file:

$objWriter = PHPExcel_IOFactory::createWriter( $objPHPExcel, 'Excel5' );
$objWriter->save( 'php://output' );


How can I add an attachment to my posts, so I could upload the corrupt file?

Thanks and Greetings,

Urkman

 

Oct 14, 2009 at 9:37 AM

Hello koyama,

I will create this two files und upload it.

Thanks for your answer,

Urkman

 

Oct 14, 2009 at 10:26 AM

Hello koyama,

I uploaded the two files. Both files are created using the same script( 01simple.php ) with the following canges:

$objWriter = PHPExcel_IOFactory::createWriter( $objPHPExcel, 'Excel5' );
$objWriter->save( 'php://output' ); 

Thanks and greetings,

Urkman

 

 

Developer
Oct 14, 2009 at 10:45 AM

I think it is a problem with the iconv extension. All text strings are blank in the binary file! Which is why the file is corrupt.

Can you try to run this simple script on both servers and post back the result:

<?php
var_dump(iconv('UTF-8', 'UTF-16LE', 'hello'));
?>

Expected result on a functioning server is this:

string(10) "h�e�l�l�o�"

Oct 14, 2009 at 11:06 AM

Output on the Windows Box( Working File ):

string(10) "h�e�l�l�o�"

 

Output on the UbuntuBox( Corrupt File ):

bool(false)

 

ICONV Part of phpinfo() on ubuntu box:

iconv
iconv support 	enabled
iconv implementation 	glibc
iconv library version 	2.3.5

Directive	Local Value	Master Value
iconv.input_encoding	ISO-8859-1	ISO-8859-1
iconv.internal_encoding	ISO-8859-1	ISO-8859-1
iconv.output_encoding	ISO-8859-1	ISO-8859-1

ICONV Part of phpinfo() on Windows box:

iconv
iconv support 	enabled
iconv implementation 	"libiconv"
iconv library version 	1.9

Directive	Local Value	Master Value
iconv.input_encoding	ISO-8859-1	ISO-8859-1
iconv.internal_encoding	ISO-8859-1	ISO-8859-1
iconv.output_encoding	ISO-8859-1	ISO-8859-1

Hope, this helps...

 

Greetings,

Urkman

 

Developer
Oct 14, 2009 at 11:27 AM

What do you get for this?

<?php
var_dump(mb_convert_encoding('hello', 'UTF-16LE', 'UTF-8'));
?>

Oct 14, 2009 at 11:46 AM

Now i get

string(10) "h�e�l�l�o�"

on both maschines...

Urkman

 

Developer
Oct 14, 2009 at 12:02 PM

I will make a simple fix today so PHPExcel detected when there is a problem with iconv and fall back to mbstring if it is available. Will post back here.

Related threads:
http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=33773
http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=61184

Developer
Oct 14, 2009 at 12:51 PM

This should fix the problem:

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

Look at patch at that link, or just wait for source code release tomorrow from here:

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