精简办法
代码如下:
<?php
/**
*
* @copyright 2007-2012 Xiaoqiang.
* @author Xiaoqiang.Wu <jamblues@gmail.com>
* @version 1.01
*/
error_reporting(E_ALL);
date_default_timezone_set('Asia/ShangHai');
/** PHPExcel_IOFactory */
require_once '../Classes/PHPExcel/IOFactory.php';
// Check prerequisites
if (!file_exists("31excel5.xls")) {
exit("not found 31excel5.xls.n");
}
$reader = PHPExcel_IOFactory::createReader('Excel5'); //设置以Excel5格式(Excel97-2003工作簿)
$PHPExcel = $reader->load("31excel5.xls"); // 载入excel文件
$sheet = $PHPExcel->getSheet(0); // 读取第一??工作表
$highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumm = $sheet->getHighestColumn(); // 取得总列数
/** 循环读取每个单元格的数据 */
for ($row = 1; $row <= $highestRow; $row++){//行数是以第1行开始
for ($column = 'A'; $column <= $highestColumm; $column++) {//列数是以A列开始
$dataset[] = $sheet->getCell($column.$row)->getValue();
echo $column.$row.":".$sheet->getCell($column.$row)->getValue()."<br />";
}
}
?>
希望本文所述对你有所帮助,php生成与读取excel文件内容就给大家介绍到这里了。希望大家继续关注我们的网站!想要学习php可以继续关注本站。







