php导出excel不知道列数 php26进制函数

function num2Letter($num) {
$num = intval($num);
if ($num <= 0)
return false;
$letterArr = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
$letter = '';
do {
$key = ($num - 1) % 26;
$letter = $letterArr[$key] . $letter;
$num = floor(($num - $key) / 26);
} while ($num > 0);
return $letter;
}

参考 https://www.cnblogs.com/shihao/archive/2012/01/12/2320675.html

猜你喜欢

转载自www.cnblogs.com/weiyiyong/p/9378695.html