Basically, this is just a quick snippet (enum) that maps to the index of a column. It makes it a little easier to see what you’re doing to match up the index to the letter it represents in Excel, especially for sheets with a ton of columns (it helps me not have to count over and over to see which column I’m actually in when programmatically creating a spreadsheet and referencing a cell). Obviously, this isn’t hard to create, but much easier to just copy and paste from here. :)
VB.Net
''' <summary>
''' Letter to Number map for Excel columns.
''' </summary>
Enum ExcelColumn
A = 0
B = 1
C = 2
D = 3
E = 4
F = 5
G = 6
H = 7
I = 8
J = 9
K = 10
L = 11
M = 12
N = 13
O = 14
P = 15
Q = 16
R = 17
S = 18
T = 19
U = 20
V = 21
W = 22
X = 23
Y = 24
Z = 25
AA = 26
AB = 27
AC = 28
AD = 29
AE = 30
AF = 31
AG = 32
AH = 33
AI = 34
AJ = 35
AK = 36
AL = 37
AM = 38
AN = 39
AO = 40
AP = 41
AQ = 42
AR = 43
[AS] = 44
AT = 45
AU = 46
AV = 47
AW = 48
AX = 49
AY = 50
AZ = 51
End Enum
C#
/// <summary>
/// Letter to Number map for Excel columns.
/// </summary>
public enum ExcelColumn
{
A = 0,
B = 1,
C = 2,
D = 3,
E = 4,
F = 5,
G = 6,
H = 7,
I = 8,
J = 9,
K = 10,
L = 11,
M = 12,
N = 13,
O = 14,
P = 15,
Q = 16,
R = 17,
S = 18,
T = 19,
U = 20,
V = 21,
W = 22,
X = 23,
Y = 24,
Z = 25,
AA = 26,
AB = 27,
AC = 28,
AD = 29,
AE = 30,
AF = 31,
AG = 32,
AH = 33,
AI = 34,
AJ = 35,
AK = 36,
AL = 37,
AM = 38,
AN = 39,
AO = 40,
AP = 41,
AQ = 42,
AR = 43,
AS = 44,
AT = 45,
AU = 46,
AV = 47,
AW = 48,
AX = 49,
AY = 50,
AZ = 51
}