I was recently asked in a job interview to resolve a programming puzzle that I thought it would be interesting to share. It\'s about translating Excel column letters to actu
Delphi:
// convert EXcel column name to column number 1..256
// case-sensitive; returns 0 for illegal column name
function cmColmAlfaToNumb( const qSRC : string ) : integer;
var II : integer;
begin
result := 0;
for II := 1 to length(qSRC) do begin
if (qSRC[II]<'A')or(qSRC[II]>'Z') then begin
result := 0;
exit;
end;
result := result*26+ord(qSRC[II])-ord('A')+1;
end;
if result>256 then result := 0;
end;
-Al.