很簡單就可以實現(xiàn),下面為大家簡單介紹下
1、下載PHPExcel類,是一個文件夾,還得有一個文件PHPExcel.php,兩個在同級目錄
require __DIR__ . './PHPExcel/IOFactory.php'; $PHPReader = new \PHPExcel_Reader_Excel2007(); //判斷文件類型 if (!$PHPReader->canRead($filePath)) { $PHPReader = new \PHPExcel_Reader_Excel5(); if (!$PHPReader->canRead($filePath)) { echo 'no Excel'; return false; } } $PHPExcel = $PHPReader->load($filePath); /**讀取excel文件中的第一個工作表*/ $currentSheet = $PHPExcel->getSheet(0); /**取得最大的列號*/ $allColumn = $currentSheet->getHighestColumn(); /**取得一共有多少行*/ $allRow = $currentSheet->getHighestRow(); /**從第1行開始輸出*/ for ($currentRow = 1; $currentRow <= $allRow; $currentRow++) { /**從第A列開始輸出*/ for ($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn++) { $val = $currentSheet->getCellByColumnAndRow(ord($currentColumn) - 65, $currentRow)->getValue(); /**ord()將字符轉(zhuǎn)為十進(jìn)制數(shù)*/ $date[$currentRow - 1][] = $val; } } return $date;
以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時也希望多多支持!
【網(wǎng)站聲明】本站除付費源碼經(jīng)過測試外,其他素材未做測試,不保證完整性,網(wǎng)站上部分源碼僅限學(xué)習(xí)交流,請勿用于商業(yè)用途。如損害你的權(quán)益請聯(lián)系客服QQ:2655101040 給予處理,謝謝支持。