0

我使用 LinqToExcel 在我的 C# 控制台应用程序中读取 Excel 文件。但是它只读取前 254 行并忽略其余行。如何排除故障?

4

1 回答 1

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);
}
于 2015-08-24T18:19:57.263 回答