D
D
I am trying to do this in C#
Function Num2Let(L As Long) As String
Dim s0 As String, s1 As String, S2 As String, s3 As String
If L > 18278 Then s0 = Chr((Int((L - 18279) / 17576) Mod 26) + 65)
If L > 702 Then s1 = Chr((Int((L - 703) / 676) Mod 26) + 65)
If L > 26 Then S2 = Chr(Num2Let & (Int((L - 27) / 26)) Mod 26 + 65)
s3 = Chr(((L - 1) Mod 26) + 65)
Num2Let = s0 & s1 & S2 & s3
End Function
it takes a long and converts it to the excel header format of AA, BQ DS etc
so far I have this, I commented out the top and worked my way up from the
bottom. I'm not sure what the c# equivalent of Int in excel (which returns
the 210 part of 210.2342) and I don't know what how this is handled
Chr(Num2Let & ( Int((L - 27) / 26) ) % 26 + 65);
Thanks for any help.
public string Num2Let(long L )
{
string s0, s1, S2, s3, final;
/* if(L > 18278)
s0 = Chr((Int((L - 18279) / 17576) % 26) + 65);
if(L > 702)
s1 = Chr((Int((L - 703) / 676) % 26) + 65);
*/
if(L > 26)
S2 = Chr(Num2Let(((L - 27) / 26)) % 26 + 65);
//S2 = Chr(Num2Let & ( Int((L - 27) / 26) ) % 26 + 65);
long x =(((L - 1) % 26) + 65);
char c = (char)x;
s3 = c.ToString();
//final = s0 + s1 + S2 + s3;
return s3;
}
Function Num2Let(L As Long) As String
Dim s0 As String, s1 As String, S2 As String, s3 As String
If L > 18278 Then s0 = Chr((Int((L - 18279) / 17576) Mod 26) + 65)
If L > 702 Then s1 = Chr((Int((L - 703) / 676) Mod 26) + 65)
If L > 26 Then S2 = Chr(Num2Let & (Int((L - 27) / 26)) Mod 26 + 65)
s3 = Chr(((L - 1) Mod 26) + 65)
Num2Let = s0 & s1 & S2 & s3
End Function
it takes a long and converts it to the excel header format of AA, BQ DS etc
so far I have this, I commented out the top and worked my way up from the
bottom. I'm not sure what the c# equivalent of Int in excel (which returns
the 210 part of 210.2342) and I don't know what how this is handled
Chr(Num2Let & ( Int((L - 27) / 26) ) % 26 + 65);
Thanks for any help.
public string Num2Let(long L )
{
string s0, s1, S2, s3, final;
/* if(L > 18278)
s0 = Chr((Int((L - 18279) / 17576) % 26) + 65);
if(L > 702)
s1 = Chr((Int((L - 703) / 676) % 26) + 65);
*/
if(L > 26)
S2 = Chr(Num2Let(((L - 27) / 26)) % 26 + 65);
//S2 = Chr(Num2Let & ( Int((L - 27) / 26) ) % 26 + 65);
long x =(((L - 1) % 26) + 65);
char c = (char)x;
s3 = c.ToString();
//final = s0 + s1 + S2 + s3;
return s3;
}