Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save elieandraos/5813283 to your computer and use it in GitHub Desktop.
Save elieandraos/5813283 to your computer and use it in GitHub Desktop.
Get Excel Column Name From Number (index)
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