修复phpExcelReader的一个小Bug

[不指定 2009/02/26 16:11 | by ipaddr ]
最近开发一个小项目,有一个基本功能就是:上传一个Excel文件到服务端,再读取Excel里面的内容写入到数据库。

在网上搜索了一下,最终确定使用phpExcelReader来读取Excel文件。

但在使用过程中,发现一些莫名的错误,有些Excel根本无法读出,尤其是文件比较大的情况下。

经过仔细阅读Excel的文件格式说明和调试phpExcelReader,发现确实是一个小Bug,在读取SST数据时,如果有多段SST数据就会出错。

本人(鱼漂)已修复了此问题,有需要的可以从此处下载。

[file]attachment/200902/phpexcelreaderfixed.rar[/file]

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();
$workbook->send("file.xls");
$workbook->setVersion(8);
$worksheet =& $workbook->addWorksheet("My worksheet");
$worksheet->setInputEncoding("UTF-8");

// .. add content to spreadsheet here
$workbook->close();




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.

[file]attachment/200902/workbook.rar[/file]

分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]