Spreadsheet_Excel_Writer PEAR Package

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Spreadsheet_Excel_Writer PEAR Package

Post by shiznatix »

I am trying to create excel files with Spreadsheet_Excel_Writer and everything was going swimmingly until I tried writing out in Portuguese and Russian. The silly encoding is just plain broken. I did some searching and ended up with this solution:

Code: Select all

 
$workbook->setVersion(8);
$worksheet->setInputEncoding('utf-8');
 
and as well as that works for setting the encoding, but it has this problem. When I try to open it in OpenOffice it does the Russian encoding well but as soon as it hits a strange letter in Portuguese it just explodes. Throws in a million question-marks everywhere and can't handle anything.

So, does anyone have any suggestions for this class that could help me get this encoding stuff to look good?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Re: Spreadsheet_Excel_Writer PEAR Package

Post by shiznatix »

Bit of a bump but I am having more problems as well. I have noticed that if I try to put a long string into one of the cells then it just truncates the string after 255 characters. Is 255 the largest amount of characters you can have in a excel cell? If so, wtf?

Does anyone have any experience with this package/class? Maybe you have had better luck with another excel file creator? Really what I am trying to do is export our translation files into 1 big excel file that we can send to a translation agency and then have it sent back and just imported nice and easy. Maybe excel is not the best / only choice for this?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Spreadsheet_Excel_Writer PEAR Package

Post by VladSun »

I've played with it, and I think it's the best excel export class you can find on the web (for free).

http://pear.php.net/manual/en/package.f ... string.php
Write a string to the specified row and column (zero indexed). NOTE: there is an Excel 5 defined limit of 255 characters. $format is optional. Returns 0 : normal termination -1 : insufficient number of arguments -2 : row or column out of range -3 : long string truncated to 255 chars
And, yes - for viewing utf-8 content the:

Code: Select all

$workbook->setVersion(8);
$worksheet->setInputEncoding('utf-8');
is the only solution I could find. I recall that it has some problems with sheetname in utf-8 though.

Sorry, but I can't help you with the Russian/Portuguese problem.
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply