問題:程序中我們用到循環的時候都是需要使用到最大列數和行數的,最大行數是數字,但列數就是列名了,如何將列名轉換成數字?
解決辦法:
使用 PHPExcel_Cell::columnIndexFromString(‘A’) //將列名轉換成功數字
完整代碼
import('PHPExcel.PHPExcel');
$objReader = \PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load($filepath);
$columnCount = $objPHPExcel->getActiveSheet()->getHighestColumn();
$columnCount = PHPExcel_Cell::columnIndexFromString($columnCount);