解决Excel上传莫名的空格,空行

来源:互联网 发布:acs数据库 编辑:程序博客网 时间:2024/05/31 18:54
Excel在Web中使用,经常会出现会读取莫名的空行,现在通过下面方法解决,虽然很简单,用途很大。FYI private DataSet CreateDataSource() { string strCon; strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("ExcelFiles//" + FileName).ToString() + ";Extended Properties=Excel 8.0;"; OleDbConnection con = new OleDbConnection(strCon);‘Before OleDbDataAdapter da = new OleDbDataAdapter("select * from [ShipmentList$] ", con);‘After OleDbDataAdapter da = new OleDbDataAdapter("select * from [ShipmentList$] S1 where Trim(S1.PONO)<>''", con); DataSet ds = new DataSet(); da.Fill(ds); return ds; }
原创粉丝点击