参考: https://www.cnblogs.com/jianqingwang/p/6830892.html
安装phpexcel
在:https://packagist.org/ 中搜索Excel, 可以发现排名最前的是 phpoffice/phpexcel
在工程目录下执行,composer require phpoffice/phpexcel.
下面分别从读已有excel 和生成excel 两个角度来进行示例。
1、 读excel:
假设读取的excel内容如下:
读取上图的代码如下:
<?php
define("BASE_DIR", str_replace("\\", '/', __DIR__));
include BASE_DIR."/vendor/autoload.php";
$inputFileName = "./test.xlsx";
date_default_timezone_set("PRC");
// 读取excel文件
try {
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
} catch(Exception $e) {
die (pathinfo