日期:2014-05-17 浏览次数:20485 次
/*
* PHPExcel.V1.7.6版本 [读取示例]
*/
include 'PHPExcel/IOFactory.php';
$filename = "d:/test.xls";
$readType = PHPExcel_IOFactory::identify($filename); //在不知道文档类型的情况下获取
$excelReader = PHPExcel_IOFactory::createReader($readType);
$PHPExcelObj = $excelReader->load($filename);
$currentSheet = $PHPExcelObj->getSheet(0); //选取第一张表单(Sheet1)为当前操作的表单
$excelRows = $currentSheet->getHighestRow(); //获取最大行
$excelColumn = $currentSheet->getHighestColumn(); //获取最大列
foreach(range(1,$excelRows) as $row){
$line = '<p>';
foreach(range('A',$excelColumn) as $column){
$line .= $currentSheet->getCell($column.$row)->getValue().",";
}
$line .= '</p>';
echo $line;
}
------解决方案--------------------