Spreadsheet_Excel_Writer and UTF8

| |
[不指定 2009/02/26 15:49 | by ipaddr ]

After recently working on an application to generate Microsoft Excel documents using a PHP script, I ran into trouble with the PEAR package "Spreadsheet Excel Writer" which didn't correctly display UTF-8 characters . Here is a fix!

You just need to replace the Workbook.php file in the Spreadsheet Excel Writer package with this patched version of the file. For more information on the problem and the patch check out the comments on the bug report page (most of the good stuff is right near the bottom).

Then your spreadsheet generation code would look something like:

$workbook = new Spreadsheet_Excel_Writer();
$worksheet =& $workbook->addWorksheet("My worksheet");

// .. add content to spreadsheet here

This worked for me with version 0.9.0 of the package and it should also work with 0.9.1. I’d expect the fix to be included in upcoming releases of the package, but until then the above patch works great.


Program | 评论(0) | 引用(0) | 阅读(5870)