function GetMyStrToInt(const s:string):integer;
var
i,j,k,t:integer;
begin
k:=length(s);
t:=0;
fori:=k down to 1 do
begin
j:=ord(s[K])-ord(A)+1;
t:=t*26+j;
end;
result:=t;
end;
这相当于26进制的运算。
我自己因涉及到Excel写过的一个数值到字母的函数,反向的请楼主自己写吧。
function int2letter(num:integer):string;
const
LetterStr='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var
i,j:integer;
begin
if num<=26 then
begin
result:=LetterStr[num];
end
else
begin
j:=num mod 26;
i:=num div 26;
if j=0 then
begin
j:=26;
i:=i-1;
end;
result:=int2letter(i)+LetterStr[j];
end;
end;
function GetMyStrToInt(const s:string):integer;
var
i,j,k,t:integer;
begin
k:=length(s);
t:=0;
fori:=k down to 1 do
begin
j:=ord(s[K])-ord(A)+1;
t:=t*26+j;
end;
result:=t;
end;