这篇文章介绍的内容是关于php获取excel表数据 ,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
/* 商户池导入*/
public function sellerpoolimport(){
import('component/phpexcel',app_path,'.php'); // 引入excel处理类
$phpreader = new \phpexcel_reader_excel2007();
$filepath = $_files['url']['tmp_name']; //获取上传文件临时目录
//判断文件类型
if (!$phpreader->canread($filepath)) {
$phpreader = new \phpexcel_reader_excel5();
if (!$phpreader->canread($filepath)) {
$this->error('请选择excel文件',u('seller/sellerpoolindex'),3);
}
}
$phpexcel = $phpreader->load($_files['url']['tmp_name']);
/**读取excel文件中的第一个工作表*/
//并且转成数组
$currentsheetarr = $phpexcel->getsheet(0)->toarray();
$res = d('seller')->sellerpoolimport(i('post.channeltype'),i('post.companycode'),$currentsheetarr);
if(!is_array($res)) $this->error($res,u('seller/sellerpoolindex'),6);
$this->success('导入成功',u('seller/sellerpoolindex'),3);
}
相关推荐:
phpexcel中文教程
以上就是php获取excel表数据的详细内容。