最近更新: 2007-03-17

php-SpreadsheetReader

Update: 2007/07/02

A PHP library for read spreadsheet files

PHP library for read data of spreadsheet files. It supports OpenDocument Spreadsheet (.ods), Microsoft Excel 97/2000 (.xls), CSV (.csv), and Text with tab-separated or patterns (.txt).

Use this command to anonymously check out the latest project source code:

 svn checkout http://php-spreadsheetreader.googlecode.com/svn/ php-spreadsheetreader

Current download link: SpreadsheetReader_rev-25.zip

This proejct is hosted in php-spreadsheetreader - Google Code. It is issued on under the GNU Lesser General Public License. For further information click here.

Todo

Plan to rewrite Excel reader with pure PHP code.
There is a PHP Excel Reader written by pure PHP code. (http://sourceforge.net/projects/phpexcelreader/) I would rewrite my Excel reader by that one. Instead of invoking the external reader, jxl.

Latest Change

Revision 24:
Add method: asXml(). This return $sheets as Xml string (Excel XML format). Therefor you can save it or put into a download stream. 可以將 $sheets 轉為 XML 字串 (Excel 2000/XP 的XML格式)。這可讓你將試算表保存為一個 XML 檔案,或加到一個檔案下載的串流中。
Revision 21:
It can return sheets as associative array. 可以將試算表結果回傳為關聯式陣列。將第一列視為欄位標頭,作為陣列的鍵值。
Revision 16:
Support MS Excel 2000/XP's XML file. Note: Excel 2000/XP's XML file format is a single XML file, and different from Office OpenXML. 支援 MS Excel 2000/XP 的 XML 格式試算表。注意: MS Excel 2000/XP 的 XML 格式試算表是一種單一XML文件,與 Office OpenXML 不同。同樣是純文字文字格式,但 Excel 2000/XP XML 較 CSV 對資料型態及中日韓文的支持更好。
Bug fixed
  • Let factory detect file-type case-insensitive.
  • Bug of SpreadsheetReader_Excel: Sometimes, data will contain non-readable chars (I put in $ignoreChar). XML parser will occur a parse error. So we need to strip those non-readable chars.
  • It only output tables which have text in their first cell. Now fix it.
  • When read with READ_ASSOC, it forgets to skip the first Row(fields header) after 2nd sheet.
php-SpreadsheetReader - A PHP library for read spreadsheet files
Copyright (C) 2006  Shih Yuncheng 
                    http://code.google.com/p/php-spreadsheetreader/

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
相關文章
樂多舊網址: http://blog.roodo.com/rocksaying/archives/2864529.html

樂多舊回應
未留名 (#comment-4215845)
Mon, 19 Mar 2007 11:59:17 +0800
Revision 14:

I add text-based sheet reader class today.

One row per line. In default, it will separate fields by tab (\t). You might set a PCRE-pattern to indicate the reader how to take fields.
未留名 (#comment-4249461)
Fri, 23 Mar 2007 09:18:49 +0800
It's a very simply library. To use it, you may look at the sources of test case (*Test.php) .

這是非常簡單的工具。看看測試案例的源碼,你就會用了。
未留名 (#comment-10886215)
Tue, 12 Jun 2007 17:04:28 +0800
SpreadsheetReader 近期重要更新內容:

Revision 16:
Support MS Excel 2000/XP's XML file.
Notice: Excel 2000/XP's XML file format is a single XML file, and different from Office OpenXML.
支援 MS Excel 2000/XP 的 XML 格式試算表。
注意: MS Excel 2000/XP 的 XML 格式試算表是一種單一XML文件,與 Office OpenXML 不同。
OpenOffice 支持 MS Excel 2000/XP 的XML格式試算表。
同樣是純文字文字格式,但 Excel 2000/XP XML 較 CSV 對資料型態及中日韓文的支持更好。

Revision 21:
Add feature: It can return sheets as associative array.
可以將試算表結果回傳為關聯式陣列。將第一列視為欄位標頭,作為陣列的鍵值。

Revision 24:
Add method: asXml(). This return $sheets as Xml string (Excel XML format). Therefor you can save it or put in a download stream.
可以將 $sheets 轉為 XML 字串 (Excel 2000/XP 的XML格式)。這可讓你將試算表保存為一個 XML 檔案,或加到一個檔案下載的串流中。

Bug fixed:
1. Let factory detect file-type case-insensitive.

2. bug of SpreadsheetReader_Excel: Sometimes, data will contain non-readable chars (I put in $ignoreChar). XML parser will occur a parse error. So we need to strip those non-readable chars.

3.It only output tables which have text in their first cell. Now fix it.

4.When read with READ_ASSOC, it forgets to skip the first Row(fields header) after 2nd sheet.
未留名 (#comment-11128813)
Wed, 04 Jul 2007 11:14:52 +0800
Revision 26
IMPORTANT! I rewrite my Excel reader by pure PHP code. Instead of invoking the external reader, jxl.