J
Johnny
Hi all:
I am trying to write some code to read an Excel spreadsheet from an ASP.NET
application. For some reason no fields that have a number in them are read,
while text data is read just fine.
I am using a connection string:
Conn1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
Conn1 += @"C:\Temp\Success Partners\Test.xls";
Conn1 += ";Extended Properties=\"Excel 8.0;HDR=YES;\"";:
and then filling a data set:
cmd1 = new System.Data.OleDb.OleDbCommand("SELECT * FROM ['Test$']", conn1);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = cmd1;
DataSet objDataset1 = new DataSet();
objAdapter1.Fill(objDataset1, "XLData");
GridView1.DataSource = objDataset1.Tables[0].DefaultView;
GridView1.DataBind();
but for some reason no numbers show up in the grid or the dataset (I parsed
through it to check the data).
Can anyone suggest what I am doing wrong and/or a better way to do this.
I found some examples that use some Interop classes to read the worksheets,
but I couldn't get those working from ASP.NET...
Thanks for any and all help.
I am trying to write some code to read an Excel spreadsheet from an ASP.NET
application. For some reason no fields that have a number in them are read,
while text data is read just fine.
I am using a connection string:
Conn1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
Conn1 += @"C:\Temp\Success Partners\Test.xls";
Conn1 += ";Extended Properties=\"Excel 8.0;HDR=YES;\"";:
and then filling a data set:
cmd1 = new System.Data.OleDb.OleDbCommand("SELECT * FROM ['Test$']", conn1);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = cmd1;
DataSet objDataset1 = new DataSet();
objAdapter1.Fill(objDataset1, "XLData");
GridView1.DataSource = objDataset1.Tables[0].DefaultView;
GridView1.DataBind();
but for some reason no numbers show up in the grid or the dataset (I parsed
through it to check the data).
Can anyone suggest what I am doing wrong and/or a better way to do this.
I found some examples that use some Interop classes to read the worksheets,
but I couldn't get those working from ASP.NET...
Thanks for any and all help.