M
mtgomes
Hello,
I'm having a problem when getting data from an excel file (source code
bellow). All works fine, however the datatable filled only has 255
columns.. The files that I'm importing are quite big (more than 1000
columns, but columns are variable), and manual parsing the file will
be quite slow..
This may be a trivial issue, however I can't seem to figure out how to
get it working.
Thanks in advance for the help.
Cheers!!
MG
Source code:
DataSet ds = new DataSet
();
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source="....xlsx";Extended Properties='Excel 12.0;HDR=No;IMEX=1;'";
OleDbConnection conn = new OleDbConnection
(connectionString);
try
{
conn.Open();
DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
null);
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = new OleDbCommand(@"SELECT * FROM [" + sheet +
"$]", conn);
da.Fill(ds);
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}
I'm having a problem when getting data from an excel file (source code
bellow). All works fine, however the datatable filled only has 255
columns.. The files that I'm importing are quite big (more than 1000
columns, but columns are variable), and manual parsing the file will
be quite slow..
This may be a trivial issue, however I can't seem to figure out how to
get it working.
Thanks in advance for the help.
Cheers!!
MG
Source code:
DataSet ds = new DataSet
();
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source="....xlsx";Extended Properties='Excel 12.0;HDR=No;IMEX=1;'";
OleDbConnection conn = new OleDbConnection
(connectionString);
try
{
conn.Open();
DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
null);
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = new OleDbCommand(@"SELECT * FROM [" + sheet +
"$]", conn);
da.Fill(ds);
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}