Header Ads

Code to get Colomn count and Name of a Excell File

Here is a simple piece of code that will give you the column.
Most of time I need row count but not the column count.But this time I need the column count.
I need to check the required number of column . If the number matches then I need to test if the particular column exists or not.

Lets check the code

Public Function GetColCount (sSheetName)
On Error Resume Next
i = i + 1
sColName = DataTable.GetSheet(sSheetName).GetParameter(i).Name
Loop While 0 = Err.Number
'GetParameter throws an error when using an index that is out of bounds ...
'We can use this functionality to ASSUME that it's an unused column.
'We've come to the end of our USED columns
GetColCount = i - 1
On Error GoTo 0
End Function

Now it is your task to find out name of the coloumn.
lets see who can do it.
Powered by Blogger.