[Test]
Public Void Test10to26 ()
{
Assert. areequal ( " A " , Getcolumnname ( 1 ));
Assert. areequal ( " B " , Getcolumnname ( 2 ));
Assert. areequal ( " Z " , Getcolumnname ( 26 ));
Assert. areequal ( " Zz " , Getcolumnname ( 26 * 26 + 26 ));
Assert. areequal ( " Zzz " , Getcolumnname ( 26 * 26 * 26 + 26 * 26 + 26 ));
Assert. areequal ( " AA " , Getcolumnname ( 27 ));
Assert. areequal ( " AB " , Getcolumnname ( 28 ));
Assert. areequal ( " AC " , Getcolumnname ( 29 ));
Int Aaa = 1 * 26 * 26 + 1 * 26 + 1 ; // AAA;
Assert. areequal ( " Aaa " , Getcolumnname (AAA ));
Int AAB = 1 * 26 * 26 + 1 * 26 + 2 ;
Assert. areequal ( " AAB " , Getcolumnname (AAB ));
Int Bbb = 2 * 26 * 26 + 2 * 26 + 2 ; // AAA;
Assert. areequal ( " Bbb " , Getcolumnname (BBB ));
}
Public String Getcolumnname ( Int Intvalue)
{
String Result = "" ;
If (Intvalue <= 26 )
{
Result = ( Char ) (Intvalue + 96 ) + Result;
Return Result. toupper ();
}
IntModof26=Intvalue% 26;
IntLeft= 0;
If (Modof26 = 0 )
{
Result = ' Z ' + Result;
Left = Intvalue - 26 ;
}
Else
{
Result = ( Char ) (Modof26 + 96 ) + Result;
Left = Intvalue - Modof26;
}
IntNextinputvalue=Left/ 26;
If(Nextinputvalue= 0)
ReturnResult. toupper ();
If (Nextinputvalue > 26 )
Result = Getcolumnname (nextinputvalue) + Result;
Else
Result = ( Char ) (Nextinputvalue + 96 ) + Result;
ReturnResult. toupper ();
}