Created
June 19, 2013 10:19
-
-
Save elieandraos/5813283 to your computer and use it in GitHub Desktop.
Get Excel Column Name From Number (index)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getExcelColumnName($num) { | |
$numeric = ($num - 1) % 26; | |
$letter = chr(65 + $numeric); | |
$num2 = intval(($num - 1) / 26); | |
if ($num2 > 0) { | |
return getExcelColumnName($num2) . $letter; | |
} else { | |
return $letter; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment