0
我想从excel中获取数据到使用OLEDB的数据集中,但我并没有将excel中的所有行都放到数据集中。我在Excel表中有243300行,但我只有44401行出现在数据集表中。Oledb不从excel中获取完整的数据到数据集
这里是代码我使用:
public DataSet GetDataSet(string SheetName)
{
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelFilePath.Text + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=0;TypeGuessRows=0'";
OleDbConnection conExcel = new OleDbConnection(connectionString);
conExcel.Open();
OleDbCommand cmd1 = new OleDbCommand("Select * from [" + SheetName + "$]", conExcel);
int cnt= cmd1.ExecuteNonQuery();
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd1);
conExcel.Close();
da.Fill(ds, "Table");
return ds;
}