excel导入导出是我们做项目中经常用到的功能,那么,今天就来说说excel导入。
一. 类文件
二. 调用代码:
<?php
require_once "phpexcel-1.8/Classes/PHPExcel.php";
require_once "phpexcel-1.8/Classes/PHPExcel/IOFactory.php";
public function actionPush()
{
$file= "../web/pan.xlsx";
$excelReader = PHPExcel_IOFactory::createReaderForFile($file);
$excelObj = $excelReader->load($file);
$worksheet = $excelObj->getSheet(0);
//获取某列的数据条数
$lastRow = $worksheet->getHighestRow('B');
//获取某列第几行的数值
$nowRow = trim($worksheet->getCell('D3')->getValue());
}
那么,获取到具体数值后,就可以根据你的业务逻辑来编写代码了。