phpexcel’s getSheet(i) can only read one page. How to get how many pages an excel has?
phpexcel’s getSheet can only read one page. How to get how many pages an excel has?
——Solution——————–
count?
——Solution——————–
//Get the number of worksheets
$sheetCount = $PHPExcel->getSheetCount();
- PHP code
canRead($filePath))
{
$PHPReader = new PHPExcel_Reader_Excel5();
if(!$PHPReader->canRead($filePath))
{
echo 'Excel file not found! ';
return;
}
}//A function to obtain all worksheet arrays without reading the entire Excel file. I feel that this function is very useful. It took me a long time to find it.
$sheetNames = $PHPReader->listWorksheetNames($filePath);//Read Excel file
$PHPExcel = $PHPReader->load($filePath);//Get the number of worksheets
$sheetCount = $PHPExcel->getSheetCount();//Select the first worksheet
$currentSheet = $PHPExcel->getSheet(0);//Get how many columns there are in total
$allColumn = $currentSheet->getHighestColumn();//Get how many rows there are in total
$allRow = $currentSheet->getHighestRow();//Loop to read data, the default encoding is utf8, here converted to gbk output
for($currentRow = 1;$currentRow<=$allRow;$currentRow++)
{
for($currentColumn='A';$currentColumngetCell($address)->getValue() )."\t";
}
echo "
";
}
?>