6. Oktober 2009 10:57
GetColumnName(pColumnNumber : Integer) retval : Text[30]
Chars:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
times1 := ROUND((pColumnNumber-1) / 702,1,'<');
IF times1 > 0 THEN
FirstChar:=COPYSTR(Chars,times1,1)
ELSE
FirstChar:='';
times2 := ROUND((pColumnNumber-(times1*702)-1) / 26,1,'<');
IF times2 > 0 THEN
SecondChar:=COPYSTR(Chars,times2,1)
ELSE BEGIN
SecondChar:='';
IF times1 > 0 THEN
SecondChar:= 'A'
END;
ThirdChar:=COPYSTR(Chars,pColumnNumber-(times1*702)-(times2*26),1);
retval := FirstChar+SecondChar+ThirdChar;
6. Oktober 2009 11:20
OBJECT Codeunit 50000 Excel Column ID
{
OBJECT-PROPERTIES
{
Date=06.10.09;
Time=11:17:42;
Modified=Yes;
Version List=;
}
PROPERTIES
{
OnRun=BEGIN
MESSAGE('Column Number: ' + FORMAT(16384) + ', ColumnID: ' + GetColumnName(16384));
END;
}
CODE
{
PROCEDURE GetColumnName@1(ColumnNumber@1000 : Integer) : Text[10];
VAR
ExcelBuffer@1001 : Record 370;
BEGIN
ExcelBuffer.VALIDATE("Column No.", ColumnNumber);
EXIT(ExcelBuffer.xlColID);
END;
BEGIN
END.
}
}
6. Oktober 2009 11:43
col:=16384;
div_val:= 26*26;
result_str:=' ';
FOR i:=3 DOWNTO 1 DO BEGIN
res := (col-1) DIV div_val;
IF (i=1) OR (res <> 0) THEN
result_str[4-i] := 65+res-(i DIV 2);
col -= res *div_val;
div_val := div_val DIV 26;
END;
MESSAGE(DELCHR(result_str));
6. Oktober 2009 12:10
6. Oktober 2009 17:33
col:=16384;
result_str:=' ';
FOR i:=3 DOWNTO 1 DO BEGIN
result_str[i] := 64+ col -((col-1) DIV 26)*26;
col := (col-1) DIV 26;
END;
MESSAGE(DELCHR(result_str,'<>',' @'));
8. Oktober 2009 08:40