返回

2016年04月18日

发布时间:2022-10-21 06:37:29 288
/**
*
* @copyright 2007-2012 Xiaoqiang.
* @author Xiaoqiang.Wu
* @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(); // 取得总列数
$highestColumm= PHPExcel_Cell::columnIndexFromString($colsNum); //字母列转换为数字列 如:AA变为27

/** 循环读取每个单元格的数据 */
for ($row = 1; $row <= $highestRow; $row++){//行数是以第1行开始
for ($column = 0; $column < $highestColumm; $column++) {//列数是以第0列开始
$columnName = PHPExcel_Cell::stringFromColumnIndex($column);
echo $columnName.$row.":".$sheet->getCellByColumnAndRow($column, $row)->getValue()."
";
}
}

?>


/**
*
* @copyright 2007-2012 Xiaoqiang.
* @author Xiaoqiang.Wu
* @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()."
";
}
}

?>


特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
精选文章
thumb 中国研究员首次曝光美国国安局顶级后门—“方程式组织”
thumb 俄乌线上战争,网络攻击弥漫着数字硝烟
thumb 从网络安全角度了解俄罗斯入侵乌克兰的相关事件时间线
下一篇
CSRF的防御实例(PHP) 2022-10-21 06:12:48