phpexcel的getSheet(i)只能讀取一頁,怎麼擷取一個excel有多少分頁?
phpexcel的getSheet只能讀取一頁,怎麼擷取一個excel有多少分頁?
------解決方案--------------------
count?
------解決方案--------------------
//擷取工作表的數目
$sheetCount = $PHPExcel->getSheetCount();
PHP code
canRead($filePath)){ $PHPReader = new PHPExcel_Reader_Excel5(); if(!$PHPReader->canRead($filePath)) { echo '未發現Excel檔案!'; return; }} //不需要讀取整個Excel檔案而擷取所有工作表數組的函數,感覺這個函數很有用,找了半天才找到$sheetNames = $PHPReader->listWorksheetNames($filePath); //讀取Excel檔案$PHPExcel = $PHPReader->load($filePath); //擷取工作表的數目$sheetCount = $PHPExcel->getSheetCount(); //選擇第一個工作表$currentSheet = $PHPExcel->getSheet(0); //取得一共有多少列$allColumn = $currentSheet->getHighestColumn(); //取得一共有多少行$allRow = $currentSheet->getHighestRow(); //迴圈讀取資料,預設編碼是utf8,這裡轉換成gbk輸出for($currentRow = 1;$currentRow<=$allRow;$currentRow++){ for($currentColumn='A';$currentColumn<=$allColumn;$currentColumn++) { $address = $currentColumn.$currentRow; echo iconv( 'utf-8','gbk', $currentSheet->getCell($address)->getValue() )."\t"; } echo "
";}?>