I have an Excel file with 500 columns. I am using OLEDB to import it into a DataTable. But the DataTable contains only the first 255 columns. I can't figure out why the rest of the columns aren't imported.
My code is
public DataTable ToDataTable()
{
DataSet dsEmpMaster = new DataSet();
DataTable dtEmpMaster = null;
string strConnectionString;
string strSql;
string FileNameWithPath = String.Format("{0}\\{1}", System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName), _FileName);
try
{
dtEmpMaster = new DataTable();
strConnectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 12.0;", FileNameWithPath);
strSql = String.Format("SELECT * FROM [{0}$]", _SheetName);
OleDbDataAdapter adpMasterData = new OleDbDataAdapter(strSql, strConnectionString);
adpMasterData.Fill(dsEmpMaster);
dtEmpMaster = dsEmpMaster.Tables[0];
adpMasterData.Dispose();
}
catch (Exception ex)
{
_ExcelError = ex.Message;
}