GET_EXCEL_COLUMN_ID returns wrong column ID
Posted: Wed Mar 09, 2016 2:33 pm
Hey Roger,
I'm not sure if this is documented anywhere, but the supporting function GET_EXCEL_COLUMN_ID() does not return the correct Excel columns value for any columns ending with a 'Z' (AZ, BZ, CZ, ...).
For example, 52nd column, which should return value 'AZ', returns 'B' instead.
Quick suggested fix:
Thanks!
I'm not sure if this is documented anywhere, but the supporting function GET_EXCEL_COLUMN_ID() does not return the correct Excel columns value for any columns ending with a 'Z' (AZ, BZ, CZ, ...).
For example, 52nd column, which should return value 'AZ', returns 'B' instead.
Quick suggested fix:
Code: Select all
FUNCTION Get_Excel_Column_ID( i )
LOCAL cAlpha := "ABCDEFGHIJKLMNOPQRSTUVWXYZ", cLastRow := ""
IF i > 26
IF Mod(i,26) = 0
cLastRow := Substr(cAlpha,Int((i-1)/26),1) + Substr(cAlpha,26,1)
ELSE
cLastRow := Substr(cAlpha,Int(i/26),1) + Substr(cAlpha,Mod(i,26),1)
ENDIF
ELSE
cLastRow := Substr(cAlpha,i,1)
ENDIF
RETURN cLastRow