php读取excel文件 php读取excel文件的简单实例

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

php读取excel文件 php读取excel文件的简单实例

  2021-03-21 我要评论
想了解php读取excel文件的简单实例的相关内容吗,在本文为您仔细讲解php读取excel文件的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:php,读取,excel,下面大家一起来学习吧。

复制代码 代码如下:

     $this->loadexcel();//半酣phpexcel文件
            $_ReadExcel = new PHPExcel_Reader_Excel2007();
            if(!$_ReadExcel->canRead('link.xls')){
            $_ReadExcel = new PHPExcel_Reader_Excel5();
            }
            $_phpExcel = $_ReadExcel->load('link.xls');
            $sheetCount = $_phpExcel->getSheetCount();
            $newExcel = array();
            $excelData = array();

            for($s = 0;$s<$sheetCount;$s++) {
                $currentSheet = $_phpExcel->getSheet($s);
                $allColumn = $currentSheet->getHighestColumn();
                $allRow = $currentSheet->getHighestRow();
                for($r = 1;$r<=$allRow;$r++){

                    for($currentColumn='A';$currentColumn<=$allColumn;$currentColumn++){
                        $address = $currentColumn.$r;
                        $newExcel[] = $currentSheet->getCell($address)->getValue();
                    }
                }
            }


后面就是对数组的操作了--不过要先下载好phpexcel,并包含进来

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们