E
Eric Sabine
I have an excel sheet with a column of mixed data types, i.e., numeric &
text. ADO.NET is scanning the first few rows and deciding on numeric so
when we come across text, the data becomes blank. That being the case I set
the extended properties setting to include IMEX=1 but this seems to be of no
help. Below is the stripped out code of what I am attempting to do. Thank
you for your help.
string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" +
Server.MapPath("~/Output/myData.xls") + ";" +
"Extended Properties=\"Excel
8.0;IMEX=1;HDR=NO;\"";
OleDbConnection oleCon = new OleDbConnection();
oleCon.ConnectionString = sConnectionString;
oleCon.Open();
OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM [2005$A5:A133]",
oleCon);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
DataSet objDataset1 = new DataSet();
objAdapter1.Fill(objDataset1);
DataGrid1.DataSource = objDataset1.Tables[0];
DataGrid1.DataBind();
oleCon.Close();
oleCon.Dispose();
text. ADO.NET is scanning the first few rows and deciding on numeric so
when we come across text, the data becomes blank. That being the case I set
the extended properties setting to include IMEX=1 but this seems to be of no
help. Below is the stripped out code of what I am attempting to do. Thank
you for your help.
string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" +
Server.MapPath("~/Output/myData.xls") + ";" +
"Extended Properties=\"Excel
8.0;IMEX=1;HDR=NO;\"";
OleDbConnection oleCon = new OleDbConnection();
oleCon.ConnectionString = sConnectionString;
oleCon.Open();
OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM [2005$A5:A133]",
oleCon);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
DataSet objDataset1 = new DataSet();
objAdapter1.Fill(objDataset1);
DataGrid1.DataSource = objDataset1.Tables[0];
DataGrid1.DataBind();
oleCon.Close();
oleCon.Dispose();