2007年03月17日

php-SpreadsheetReader

php library 自由軟體
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

Posted by shirock at 樂多Roodo! │10:41 │回應(4)引用(3)PHP
樂多分類:網路/3C 工具:編輯本文
Ads by Roodo! 

引用URL

http://cgi.blog.roodo.com/trackback/2864529
引用列表:
the temporary filename of the file in which the uploaded file was stored on the server is not the same as source filename. If you pass the temporary filename to SpreadsheetReaderFactory, it could not detect which reader to suit.
Read an uploaded spreadsheet document by php-SpreadsheetReader【石頭閒語】 at 2007年03月19日 11:38
Note of creating a MS Excel 2000/XP XML spreadsheet document by SimpleXML.
A note of creating XML document by SimpleXML 【石頭閒語】 at 2007年04月10日 17:51
以 PHP SimpleXML 實踐 MS Excel 2k/XP XML 文件之匯出工作
以 SimpleXML 將 CSV 文件轉換成 MS Excel 2k/XP XML 文件【石頭閒語】 at 2007年04月17日 17:14
回應文章
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.
Posted by 遊手好閒的石頭成 at 2007年03月19日 11:59
It's a very simply library. To use it, you may look at the sources of test case (*Test.php) .

這是非常簡單的工具。看看測試案例的源碼,你就會用了。
Posted by 遊手好閒的石頭成 at 2007年03月23日 09:18
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.
Posted by 遊手好閒的石頭成 at 2007年06月12日 17:04
Revision 26
IMPORTANT! I rewrite my Excel reader by pure PHP code. Instead of invoking the external reader, jxl.
Posted by 遊手好閒的石頭成 at 2007年07月4日 11:14