By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,034 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,034 IT Pros & Developers. It's quick & easy.

Data From Excel File Range not Found

P: n/a
I wrote an application to pull data from certain ranges of an Excel workbook.

The application works great for the first 2 of 4 sections I created. I
created the third section of code and the code is correct; however, it isn't
pulling the data.

Below is a short / complete version of the page. I verified the problem is
not in the code. I did this by copying the original file to a new file
(copied all the cells, not the physical file). The new file ran just as
expected. I can't post the original file due to the nature of its contents,
but I can explain the file.

The (original) file had frozen panes (which I unfroze to no avail). The
file also had a few locked cells which I unlocked to no avail. I know the
range names are correct because I checked them a million times.

The code listed below will write out an exception saying 'Range01' was not
found in the file. Then it will bomb on the datagrid binding since it isn't
in a try block (it is in the real program). When I change to any other file
with 'Range01' in the file it works just fine. The cell types are the same
for all the excel files I have tested, they are of type Number.

I can procede with the new file, but I would like to know what is causing
the problems so if there are issues down the line I know what to change.

Thanks,
Ryan

'Code:
Protected Holder As System.Web.UI.WebControls.PlaceHolder
Protected eConn As OleDbConnection
Protected eData As DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load

eConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " + _
"Data Source=" + Server.MapPath("[EXCEL_FILE_HERE]") + _
";" + "Extended Properties=Excel 8.0;")

Dim eSQL As String = "SELECT * FROM Range01"
Dim eCmd As New System.Data.OleDb.OleDbDataAdapter(eSQL, eConn)

Try
eData = New System.Data.DataSet()
eCmd.Fill(eData)
Catch ex As Exception
Response.Write("<br><br>" + ex.ToString())
Response.Flush()
End Try

Dim dg As New DataGrid()
dg.DataSource = eData
dg.DataBind()
Holder.Controls.Add(dg)

eData.Clear() : eData.Dispose()
eConn.Dispose()
End Sub
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I searched everywhere I could think on the net and can't find anything that
could be causing this problem. If anyone knows, please drop a line. The
code looks just fine, so I don't see how that could be causing the problem.

Is there a better newsgroup to post this question?

"Ryan Riddell" wrote:
I wrote an application to pull data from certain ranges of an Excel workbook.

The application works great for the first 2 of 4 sections I created. I
created the third section of code and the code is correct; however, it isn't
pulling the data.

Below is a short / complete version of the page. I verified the problem is
not in the code. I did this by copying the original file to a new file
(copied all the cells, not the physical file). The new file ran just as
expected. I can't post the original file due to the nature of its contents,
but I can explain the file.

The (original) file had frozen panes (which I unfroze to no avail). The
file also had a few locked cells which I unlocked to no avail. I know the
range names are correct because I checked them a million times.

The code listed below will write out an exception saying 'Range01' was not
found in the file. Then it will bomb on the datagrid binding since it isn't
in a try block (it is in the real program). When I change to any other file
with 'Range01' in the file it works just fine. The cell types are the same
for all the excel files I have tested, they are of type Number.

I can procede with the new file, but I would like to know what is causing
the problems so if there are issues down the line I know what to change.

Thanks,
Ryan

'Code:
Protected Holder As System.Web.UI.WebControls.PlaceHolder
Protected eConn As OleDbConnection
Protected eData As DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load

eConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " + _
"Data Source=" + Server.MapPath("[EXCEL_FILE_HERE]") + _
";" + "Extended Properties=Excel 8.0;")

Dim eSQL As String = "SELECT * FROM Range01"
Dim eCmd As New System.Data.OleDb.OleDbDataAdapter(eSQL, eConn)

Try
eData = New System.Data.DataSet()
eCmd.Fill(eData)
Catch ex As Exception
Response.Write("<br><br>" + ex.ToString())
Response.Flush()
End Try

Dim dg As New DataGrid()
dg.DataSource = eData
dg.DataBind()
Holder.Controls.Add(dg)

eData.Clear() : eData.Dispose()
eConn.Dispose()
End Sub

Nov 18 '05 #2

P: n/a
Well another section of the project is having the same issue now. I tried
copying the data to a new Excel file with no luck.

Has anyone ever had experience with this before?

"Ryan Riddell" wrote:
I wrote an application to pull data from certain ranges of an Excel workbook.

The application works great for the first 2 of 4 sections I created. I
created the third section of code and the code is correct; however, it isn't
pulling the data.

Below is a short / complete version of the page. I verified the problem is
not in the code. I did this by copying the original file to a new file
(copied all the cells, not the physical file). The new file ran just as
expected. I can't post the original file due to the nature of its contents,
but I can explain the file.

The (original) file had frozen panes (which I unfroze to no avail). The
file also had a few locked cells which I unlocked to no avail. I know the
range names are correct because I checked them a million times.

The code listed below will write out an exception saying 'Range01' was not
found in the file. Then it will bomb on the datagrid binding since it isn't
in a try block (it is in the real program). When I change to any other file
with 'Range01' in the file it works just fine. The cell types are the same
for all the excel files I have tested, they are of type Number.

I can procede with the new file, but I would like to know what is causing
the problems so if there are issues down the line I know what to change.

Thanks,
Ryan

'Code:
Protected Holder As System.Web.UI.WebControls.PlaceHolder
Protected eConn As OleDbConnection
Protected eData As DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load

eConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " + _
"Data Source=" + Server.MapPath("[EXCEL_FILE_HERE]") + _
";" + "Extended Properties=Excel 8.0;")

Dim eSQL As String = "SELECT * FROM Range01"
Dim eCmd As New System.Data.OleDb.OleDbDataAdapter(eSQL, eConn)

Try
eData = New System.Data.DataSet()
eCmd.Fill(eData)
Catch ex As Exception
Response.Write("<br><br>" + ex.ToString())
Response.Flush()
End Try

Dim dg As New DataGrid()
dg.DataSource = eData
dg.DataBind()
Holder.Controls.Add(dg)

eData.Clear() : eData.Dispose()
eConn.Dispose()
End Sub

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.