Get Column Name from Column Number of Microsoft Excel in Dynamics AX 2009 by X++ Code
str xppColumnNum2ColumnName(counter _excelColumn)
{
str returnRange;
int temp;
int modvalue;
int divValue = _excelColumn;
str 1 returnColumnName(counter _alphaPos)
{
temp = 64 + _alphaPos;
return num2char(temp);
}
;
while(true)
{
if(divValue > 26)
{
modvalue = divValue mod 26;//will always be equal or less than 26
divValue = divValue div 26;//can be greater than 26
returnRange += returnColumnName(modvalue);
}
else
{
returnRange += returnColumnName(divvalue);
break;
}
}
return strReverse(returnRange);
}
No comments:
Post a Comment