Home > Backend Development > PHP Tutorial > A simple example of reading excel files in php_PHP tutorial

A simple example of reading excel files in php_PHP tutorial

WBOY
Release: 2016-07-21 14:59:11
Original
856 people have browsed it

复制代码 代码如下:

     $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,并包含进来

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/328155.htmlTechArticle复制代码 代码如下: $this-loadexcel();//半酣phpexcel文件 $_ReadExcel = new PHPExcel_Reader_Excel2007(); if(!$_ReadExcel-canRead('link.xls')){ $_ReadExcel = new PHPExcel_...
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