phpexcelreader超級簡單使用

來源:互聯網
上載者:User

標籤:style   blog   http   color   使用   strong   檔案   資料   

phpexcelreader超級簡單使用

 

該php類可以到官網下載:http://www.codeplex.com/PHPExcel,下載的檔案不能直接使用要看下面的備忘。

備忘:

1、要將oleread.inc改成oleread.php,修改檔案名稱。

2、要將reader.php中的第31段代碼:require_once ‘Spreadsheet/Excel/Reader/OLERead.php‘;

   改成 備忘1的檔案路徑:require_once ‘oleread.php’ (假設oleread.php與reader.php在同一目錄下)

3、當出現錯誤碼:Deprecated: Assigning the return value of new by reference is deprecated。說明你的php版本大於5.3了,而5.3不支援”=&”符號,支援”=”符號,所以要將reader.php檔案中的”=&”符號全部替換為”=”符號。

4、本身內建的jxlrwtest.xls的檔案有錯誤,需要自己建立一個新的xls檔案來測試

5、其他一些亂碼什麼問題的,這裡就不解釋了,看標題你懂得(簡單使用)

 

代碼功能:顯示該xls檔案的全部資料

 #test.xls  要匯入的xls檔案

 #$data->sheets[0][‘numRows‘]  擷取最大的行數

 #$data->sheets[0][‘numCols‘]  擷取最大的列數

 #$data->sheets[0][‘cells‘][$i][$j]  擷取某個儲存格的資料

<?phprequire_once ‘reader.php‘;
$data = new Spreadsheet_Excel_Reader();$data->read(‘test.xls‘);
for ($i = 1; $i <= $data->sheets[0][‘numRows‘]; $i++) { for ($j = 1; $j <= $data->sheets[0][‘numCols‘]; $j++) { echo "\"".$data->sheets[0][‘cells‘][$i][$j]."\","; } echo "<br/>";}

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.