Home > Backend Development > PHP Tutorial > PHP导入Excel

PHP导入Excel

WBOY
Release: 2016-06-23 14:34:11
Original
947 people have browsed it

PHP实现Excel的导入,可以使用到Spreadsheet_Excel_Reader这个类库,具体代码记录如下:

<?php//调用Readerrequire_once 'Spreadsheet/Excel/Reader/reader.php';$data = new Spreadsheet_Excel_Reader();//设置文本输出编码$data->setOutputEncoding('utf-8');//读取Excel文件$data->read(文件路径);//$data->sheets[0]['numRows']为Excel行数for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {  //$data->sheets[0]['numCols']为Excel列数  for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {   //显示每个单元格内容   echo $data->sheets[0]['cells'][$i][$j];  }}?>
Copy after login

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template