php 读取 excel
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
/** Include PHPExcel_IOFactory */
require_once dirname(__FILE__) . '/PHPExcel/Classes/PHPExcel/IOFactory.php';
$file = 'qd.xls';
if (!file_exists($file)) {
exit("文件不存在" . EOL);
}else{
echo date('H:i:s') , " 开始加载excel2007 " , EOL;
}
$callStartTime = microtime(true);
echo "string";
$objPHPExcel = PHPExcel_IOFactory::load($file);
echo "string";
$callEndTime = microtime(true);
echo "string";
$sheet = $objPHPExcel->getSheet(0); // 读取第一個工作表
$highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumm = $sheet->getHighestColumn(); // 取得总列数
echo $highestRow .'--'. $highestColumm ;
$data = [] ;
/** 循环读取每个单元格的数据 */
for ($row = 1; $row <= $highestRow; $row++){//行数是以第1行开始
$dataset = [];
for ($column = 'A'; $column <= $highestColumm; $column++) {//列数是以A列开始
$dataset[] = $sheet->getCell($column.$row)->getValue();
}
$data[] = $dataset;
}
print_r($data);