<?php
function CabecalhoPlanilha( $numero ) {
$string = '';
while( $numero ) {
$string = chr( 65 + ( --$numero % 26 ) ) . $string; $numero = (int) ( $numero / 26 );
}
return $string;
}
echo CabecalhoPlanilha( 26 ) . "\n";
echo CabecalhoPlanilha( 27 ) . "\n";
echo CabecalhoPlanilha( 1024 ) . "\n";
?>
PD9waHAKCWZ1bmN0aW9uIENhYmVjYWxob1BsYW5pbGhhKCAkbnVtZXJvICkgewoJCSRzdHJpbmcgPSAnJzsKCQl3aGlsZSggJG51bWVybyApIHsKCQkJJHN0cmluZyA9IGNociggNjUgKyAoIC0tJG51bWVybyAlIDI2ICkgKSAuICRzdHJpbmc7CgkJCSRudW1lcm8gPSAoaW50KSAoICRudW1lcm8gLyAyNiApOwoJCX0KCQlyZXR1cm4gJHN0cmluZzsKCX0KCQoJZWNobyBDYWJlY2FsaG9QbGFuaWxoYSggMjYgKSAuICJcbiI7CgllY2hvIENhYmVjYWxob1BsYW5pbGhhKCAyNyApIC4gIlxuIjsKCWVjaG8gQ2FiZWNhbGhvUGxhbmlsaGEoIDEwMjQgKSAuICJcbiI7Cj8+