logo  VB.Net -Spreadsheet Column Headings
This Chapter
File Attributes
Binary File
Column Header
Copy Delete ...
CSV File
File Path
Text File
Chapters
Home Page
Colours, RGB
Computer Specifications
Dates&Times
Disk Drives
Files
Folders
GPS and OS Ref
VB.Net Forms
Image Files
If & Select
List/Array
Mathematics
NuGet
Sound
String Functions
Sun and Moon
User Controls
Validation
DigitalDan Sites
My Other Sites
Contact Site

Note
Some pages
may contain
inaccuracies
Hits=5
These functions convert spreadsheet column headers (A, B..., Z, AA, AB ...) to column numbers (0, 1..., 25, 26 ...)

Public Function SpreadsheetHeaderToColumn(co As String) As Integer
 co = co.ToUpper()
 Dim ret As Integer = 0
 For i As Integer = 0 To co.Length - 1
  ret *= 26
  ret += Char.GetNumericValue(co(i)) - 64
 Next
 Return ret
End Function

Public Function ColumnToSpreadsheetHeader(n As Integer) As String
 Dim co As String = String.Empty
 Dim m As Integer
 While n > 0
  m = (co - 1) Mod 26
  co = Chr(Asc("A") + m) & co
  n = (n - m) / 26
 End While
 Return co
End Function
  

DigitalDan.co.uk