I’m trying to read an excel file into a DataTable but IMEX driver does not read all the data in the column. What is the problem in this?
OleDbConnection dCon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=HDR=YES;Excel 12.0;IMEX=1");
Here is the code.
OleDbConnection dCon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
fileName + ";Extended Properties=HDR=YES;Excel 12.0;IMEX=1");
OleDbDataAdapter dAdp = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", dCon);
dAdp.TableMappings.Add("tbl", "Table");
dAdp.Fill(dSet);
DataTable dT = dSet.Tables[0];
for (int i = 0; i < dT.Rows.Count; i++)
{
//code for getting the values.
}
The problem is that there’s a limit to 255 Characters doing it this way.
You will maybe need to look at using the
Microsoft.Office.Interop.Excelassembly for a better solution.http://www.dotnetperls.com/excel