phpexcel

来源:互联网 发布:中国网络日报T大漠鱼T 编辑:程序博客网 时间:2024/06/06 06:57
读取文件private function import($filepath){    $this->ci->load->library('PHPExcel');    $PHPReader = new PHPExcel_Reader_Excel5();    $PHPExcel = $PHPReader->load($filepath);    /**读取excel文件中的第一个工作表*/    $currentSheet = $PHPExcel->getSheet(0);    /**取得最大的列号*/    $allColumn = $currentSheet->getHighestColumn();    /**取得一共有多少行*/    $allRow = $currentSheet->getHighestRow();    /**从第二行开始输出,因为excel表中第一行为列名*/    for($currentRow = 2;$currentRow <= $allRow;$currentRow++) {        /**ord()将字符转为十进制数*/         $valA= $currentSheet->getCellByColumnAndRow(ord('A') - 65,$currentRow)->getValue();        $valB = $currentSheet->getCellByColumnAndRow(ord('B') - 65,$currentRow)->getValue();        $valC = $currentSheet->getCellByColumnAndRow(ord('C') - 65,$currentRow)->getValue();        // 新增        action code...    }}
原创粉丝点击