Select all Sheet from an Excel File
basically, i am uplaoding a dynamic excel file and i want to select all the sheets containing a data and have it in a dataset. But i dont know how, all I can get is from a static sheet name and only one sheet per select, how can i select all shhet within one excel file and have it in a dataset? thanks.
this is what i got so far
Dim exCon开发者_运维技巧S As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
excelfile & ";Extended Properties=Excel 8.0;"
Dim exCon As New OleDbConnection(exConS)
Dim dsExcel As New DataSet()
Dim sExcel As String = "SELECT * FROM [SSI-data3$]"
Dim daExcel As New OleDbDataAdapter(sExcel, exCon)
daExcel.Fill(dsExcel)
I think you can use GetSchema with suitable schema name from the Jet schema set to retrieve the names of tables - in Excel, this includes both named ranges and sheets.
You would have to create a UNION query to get every sheet in the one set of data, which would only be suitable if the columns matched.
I think you should use Microsoft.Office.Interop.Excel
to get worksheet names and then with a foreach
you can get them
精彩评论