excel数据导入问题
这是我写的代码:
private void simpleButton7_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
ofd.Filter = "Excel文件(*.xls)|*.xls";
ofd.ShowDialog();
string filename = ofd.FileName;
string str = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";Extended Properties=Excel 8.0";
try
{
OleDbConnection con = new OleDbConnection(str);
OleDbDataAdapter ada = new OleDbDataAdapter("select * from [sheet1$]", con);
ada.Fill(Ds, "sheet");
}
catch (Exception)
{
}
gridControl1.DataSource = Ds.Tables["sheet"];
}
在导入一个空的excel的时候就会在gridControl1里面插入一条的空的数据,在导入有数据的excel时候就是好的。
请大家帮帮我怎么不让插入这一条空的行。