S
Sandy
I have an asp.net app that allows users to upload excel spreadsheets,
opens them, displays the data, allows manipulation and then inserts
the results into a SQL database.
It works fine as long as the name of the sheet is 'Sheet1'. Is there a
way to read Sheet1 without knowing what its' name is?
Here is what I am doing right now:
<code>
Dim myds As New DataSet
Dim MyExcelConnectStr As String =
"Provider=Microsoft.Jet.OLEDb.4.0;data source=" & strFileName &
";Extended Properties=""Excel 8.0;HDR=No;IMEX=1"""
strExcelSQL = "Select * from [Sheet1$]"
Dim MyOleADapter As New OleDb.OleDbDataAdapter(strExcelSQL,
MyExcelConnectStr)
MyOleADapter.Fill(myds, "xlsdata")
</code>
When Sheet1 has a different name this of course crashes. I could tell
people the sheet MUST be named Sheet1 but that is not my preference.
opens them, displays the data, allows manipulation and then inserts
the results into a SQL database.
It works fine as long as the name of the sheet is 'Sheet1'. Is there a
way to read Sheet1 without knowing what its' name is?
Here is what I am doing right now:
<code>
Dim myds As New DataSet
Dim MyExcelConnectStr As String =
"Provider=Microsoft.Jet.OLEDb.4.0;data source=" & strFileName &
";Extended Properties=""Excel 8.0;HDR=No;IMEX=1"""
strExcelSQL = "Select * from [Sheet1$]"
Dim MyOleADapter As New OleDb.OleDbDataAdapter(strExcelSQL,
MyExcelConnectStr)
MyOleADapter.Fill(myds, "xlsdata")
</code>
When Sheet1 has a different name this of course crashes. I could tell
people the sheet MUST be named Sheet1 but that is not my preference.