php ExcelReader讀取excel檔案

來源:互聯網
上載者:User

一、   概述

php教程-excelreader   是一個讀取 excel xsl   檔案內容的一個 php   類。

它的下載網址:  http://sourceforge.net/projects/phpexcelreader/

本部落格下載地址:phpexcelreader.zip

測試用excel檔案:測試.xls

檔案名稱: phpexcelreader.zip

包含兩個必需檔案: oleread.inc   、 reader.php   。其它檔案是一個應用例子 ,   讀我檔案等

二、   檔案使用

首先 ,   包含 reader   類檔案: require_once " reader.php";

建立一個執行個體: $xl_reader= new spreadsheet_excel_reader ( );

設定編碼資訊: $xl_reader ->setoutputencoding('utf-8');//不設定可能會是亂碼 要和網頁顯示編碼一致

讀取 excel   檔案資訊: $xl_reader->read("filename.xls");

它將匯出 excel   檔案中所有可以識別的資料存放區在一個對象中。資料存放區在 2   個數組中,目前沒有提供方法 /   函數訪問這些資料 .   可以像下面這樣簡單的使用數組名。

sheets   數組包含了讀取入對象的大量資料。它將匯出 excel   檔案中所有可以識別的資料存放區在一個 2   維數組中 $xl_reader->sheets[x][y]   。 x  為文檔中的表序號, y  是以下的某個參數 :

①        numrows -- int --  表的行數

例如: $rows = $xl_reader->sheets[0]['numrows']

②        numcols -- int --  表的列數

例如: $cols = $xl_reader->sheets[0]['numcols']

③        cells -- array --  表的實際內容。是一個 [row][column]   格式的 2   維數組

    例如: $cell_2_4 = $xl_reader->sheets[0]['cells'][2][4] //   行 2,   列 4   中的資料

④        cellsinfo -- array --  表格中不同資料類型的資訊。每個都包含了表格的未經處理資料和類型。這個數組包含 2   部分: raw --  表格未經處理資料; type --  資料類型。

註:只顯示非文本資料資訊。

例如: $cell_info = $xl_reader[0]['cellsinfo'][2][4]

$cell_info['raw'] is the raw data from the cell

$cell_info['type'] is the data type

$xl_reader->sheets

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.