PHP导入Excel

WBOY
WBOYOriginal
2016-06-23 14:34:11944browse

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];  }}?>

 

Statement:
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
Previous article:PHP in_array() 函数Next article:php mysql 配置