Home > Backend Development > PHP Tutorial > php gets excel table data

php gets excel table data

不言
Release: 2023-03-24 18:08:02
Original
2213 people have browsed it

The content of this article is about php to obtain excel table data. It has a certain reference value. Now I share it with everyone. Friends in need can refer to it

/* 商户池导入*/
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);
}
Copy after login

Related recommendations:

phpexcel Chinese tutorial


The above is the detailed content of php gets excel table data. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template