IntCol2Alpha Function
Takes a Numeric Column Heading and converts it to its Alphabetic Column Heading like that used in Excel.

Unit
QESBPCSConvert

Declaration
Function IntCol2Alpha(const Col: Word): string;

Description
If Col is 0 then empty string returned. If Col evaluates to greater than 'ZZ' then '**' is returned.

Parameters
Col Column Number, where 1 is the first Column

Returns
Alphabetic Column Heading like 'A' or 'BC'.

Category
String/Integer Conversion Routines

Implementation

function IntCol2Alpha (const Col: Word): string;
var
     X: Word;
begin
     if Col > 0 then
     begin
          if Col < 27 then
               Result := Char (Col + 64)
          else
          begin
               X := (Col - 1) div 26;
               if X > 26 then
                    Result := '**'
               else
                    Result := Char (X + 64) + Char ((Col - 1) mod 26 + 65)
          end;
     end
     else
          Result := ''
End;


HTML generated by Time2HELP
http://www.time2help.com