最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHPEXCEL导入excel表格生成数组
时间:2022-06-24 17:57:54 编辑:袖梨 来源:一聚教程网
代码如下 | 复制代码 |
/** * @desc PHPEXCEL导入 * return array(); */ function importExcel($file) { require_once 'PHPExcel.php'; require_once 'PHPExcel/IOFactory.php'; require_once 'PHPExcel/Reader/Excel5.php'; $objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2007 for 2007 format $objPHPExcel = $objReader->load($file); $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); // 取得总行数 $highestColumn = $sheet->getHighestColumn(); // 取得总列数 $objWorksheet = $objPHPExcel->getActiveSheet(); $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); $excelData = array(); for ($row = 1; $row <= $highestRow; $row++) { for ($col = 0; $col < $highestColumnIndex; $col++) { $excelData[$row][] =(string)$objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); } } return $excelData; } //用法: importExcel('test.xsl'); |
相关文章
- 《花亦山心之月》玉泽角色大全 06-20
- 最新正规全球交易平台虚拟币交易榜单-最安全数字资产交易平台币安推荐 06-20
- RED币手续费低吗?2025币安交易所低成本教程 06-20
- 《潮汐守望者》刺浪杀手瑞扎戈有哪些技能 06-20
- 2025年韩元炒币仅次于美元!韩国崛起为全球第二大加密货币市场 06-20
- Visa携手Yellow Card加速非洲稳定币应用 06-20