Category Archives: ASP.NET

ASP.NET: VB Ole Get the Names of Potential Worksheets in MS Excel File.

How to get the name of all possible worksheets in a Microsoft Excel File.
ExcelWorksheets

Imports System.IO
Imports System.Data
Imports System.Data.OleDb
Dim con As System.Data.OleDb.OleDbConnection
con = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;" 
& "data source=C:\ExcelFile.xls;Extended Properties=Excel 8.0;")
con.Open()
Dim dtSheets As DataTable =
    con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
Dim drSheet As DataRow
For Each drSheet In dtSheets.Rows
    ''Here are all your possible worksheets.
    ''drSheet("TABLE_NAME").ToString()
Next