我使用LinqToExcel在我的C#控制台应用程序中读取Excel文件。但是它只读取前254行并忽略其余行。如何解决问题?
答案 0 :(得分:0)
我使用相同的电子表格尝试了以下代码,它也只读取了前254行:
OleDbCommand cmd = new OleDbCommand();
OleDbDataAdapter da = new OleDbDataAdapter();
DataSet ds = new DataSet();
string connString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1""", srcFile);
string query = string.Format(@"SELECT * FROM [sheet1$A2:AD600000] WHERE ([SourceAD Domain] = ""Contos"")", numberOfRows);
OleDbConnection conn = new OleDbConnection(connString);
if (conn.State == ConnectionState.Closed) conn.Open();
try
{
cmd = new OleDbCommand(query, conn);
da = new OleDbDataAdapter(cmd);
da.Fill(ds);
}catch (Exception ex){
logger.Error(ex);
}