A
Anber
With VB.NET (Visual Studio 2005), I am trying to read a range of cells from
an Excel-sheet, where the first rows and columns are empty. It's a sheet I
just created in Excel, so there has never been data in the first rows and
columns before. The actual data in the sheet starts at C4.
When I try to read a block of values which contains only empty cells, f.e.
A1:B2, ExecuteReader hangs.
Here is my code:
Dim ExcelConnectionString As String
Dim ExcelConnection As OleDbConnection
ExcelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
ExcelConnectionString += "C:\Temp\Test1.xls"
ExcelConnectionString += ";Extended Properties=""Excel
8.0;HDR=NO;IMEX=1"""
ExcelConnection = New OleDbConnection(ExcelConnectionString)
ExcelConnection.Open()
Dim command As New OleDbCommand("SELECT * FROM [Sheet1$A1:B2]",
ExcelConnection)
Dim reader As OleDbDataReader
reader = command.ExecuteReader()
When I open Excel, add values to the above range, then remove these values
and start the code again, the code works fine, the reader contains no rows
and that's what I want.
Does anyone know what's happening here?
an Excel-sheet, where the first rows and columns are empty. It's a sheet I
just created in Excel, so there has never been data in the first rows and
columns before. The actual data in the sheet starts at C4.
When I try to read a block of values which contains only empty cells, f.e.
A1:B2, ExecuteReader hangs.
Here is my code:
Dim ExcelConnectionString As String
Dim ExcelConnection As OleDbConnection
ExcelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
ExcelConnectionString += "C:\Temp\Test1.xls"
ExcelConnectionString += ";Extended Properties=""Excel
8.0;HDR=NO;IMEX=1"""
ExcelConnection = New OleDbConnection(ExcelConnectionString)
ExcelConnection.Open()
Dim command As New OleDbCommand("SELECT * FROM [Sheet1$A1:B2]",
ExcelConnection)
Dim reader As OleDbDataReader
reader = command.ExecuteReader()
When I open Excel, add values to the above range, then remove these values
and start the code again, the code works fine, the reader contains no rows
and that's what I want.
Does anyone know what's happening here?