Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have an app that reads excel spreadsheets. It works fine, as long as the
first sheet is called "Sheet1". If there is no sheet called Sheet1 it crashes. I don't want to force the user to change the spreadsheet, I want to read the first page no matter what it is called. Here is how my code works 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") intRows = myds.Tables(0).Rows.Count intFields = myds.Tables(0).Columns.Count </code Is there some function or code that can be used in place of: strExcelSQL = "SELECT * FROM [Sheet1$]" which will provide the same function (open sheet1) without knowing it's name? (which may not be Sheet1). Or, a way to GET the first sheets name (vb.net)? Thanks. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Knowing the number | Excel Discussion (Misc queries) | |||
getting a y-value from a graph knowing the corresponding x-value | Excel Discussion (Misc queries) | |||
In Excel 2000, How do you select the whole of a worksheet (Select. | Excel Discussion (Misc queries) | |||
In Excel 2000, How do you select the whole of a worksheet (Select. | Excel Discussion (Misc queries) | |||
Auto Select a file not knowing its specific name | Excel Programming |