GET_EXCEL_COLUMN_ID returns wrong column ID

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
SvenVazan
Posts: 12
Joined: Sun May 03, 2015 11:35 am

GET_EXCEL_COLUMN_ID returns wrong column ID

#1 Post by SvenVazan »

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:

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
Thanks!

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: GET_EXCEL_COLUMN_ID returns wrong column ID

#2 Post by rdonnay »

Sven -

Thank you for that fix.

I added it to my source and it will be in build 264.

Roger
The eXpress train is coming - and it has more cars.

Post Reply