首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

phpexcel 读取xls资料

2012-08-28 
phpexcel 读取xls文件? require excel/PHPExcel.php //加载文件$filenameD:/wamp/www/test/sysoa.xls

phpexcel 读取xls文件
?phpexcel 读取xls资料

    require 'excel/PHPExcel.php'; //加载文件 $filename="D:/wamp/www/test/sysoa.xls"; //读取2003以及之前版本的xls文件 $phpreader=new PHPExcel_Reader_Excel5(); if($phpreader->canRead($filename)){ $excel=$phpreader->load($filename); //取得当前worksheet $cursheet=$excel->getSheet(0); //取得共有多少列,若不使用此静态方法,获得的$col是文件列的最大的英文大写字母 $col=PHPExcel_Cell::columnIndexFromString($cursheet->getHighestColumn()); //取得共有多少行 $row=$cursheet->getHighestRow(); //循环获取数据,xls文件是列在前行在后比如第一行第二列,实际上xls是以B2来表达的 for($currow=1;$currow<=$row;$currow++){ for($curcol=1;$curcol<=$col;$curcol++){ $result=$cursheet->getCellByColumnAndRow($curcol,$currow)->getValue(); if($result){ echo '第'.$currow.'行第'.$curcol.'列:'.$result.'&nbsp;&nbsp;'; } } echo '</br>'; } }
    ? 不过还有一些问题没有解决,我在读取另外一个xls文件时, $row=$cursheet->getHighestRow();获得的值竟然是65522,实在让人纳闷,但换一个又好了 1 楼 pz9042 2012-06-06   。。。这是我写的。。

热点排行