php获取excel表数据

php教程评论1.4K views阅读模式

这篇文章介绍的内容是关于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表数据的详细内容,更多请关注php教程网其它相关文章!

企鹅博客
  • 本文由 发表于 2020年9月27日 19:47:56
  • 转载请务必保留本文链接:https://www.qieseo.com/247853.html

发表评论