将excel的列索引转换为相应字母。
function numtochar(num: integer): string;
var
str:string;
m_num,num1,num2:integer;
begin
m_num:=num;
str:='';
num1:=m_num div 26;
num2:=m_num mod 26;
while num1>0 do
begin
if num2>0 then
str:=char(num2-1+ord('A'))+str
else
begin
str:='Z'+str;
num1:=num1-1;
end;
m_num:=num1;
num1:=m_num div 26;
num2:=m_num mod 26;
end;
if num2>0 then
str:=char(num2-1+ord('A'))+str;
Result:=str;
end;
var
str:string;
m_num,num1,num2:integer;
begin
m_num:=num;
str:='';
num1:=m_num div 26;
num2:=m_num mod 26;
while num1>0 do
begin
if num2>0 then
str:=char(num2-1+ord('A'))+str
else
begin
str:='Z'+str;
num1:=num1-1;
end;
m_num:=num1;
num1:=m_num div 26;
num2:=m_num mod 26;
end;
if num2>0 then
str:=char(num2-1+ord('A'))+str;
Result:=str;
end;