标签:
DataTable dt = new DataTable(tableName); for (int i = 0; i < columnsNames.Length; i++) { dt.Columns.Add(columnsNames[i].ToString()); } DataView dv = new DataView(dt); DataSet ds = ConnExcel(path); //过滤空白行 DataTable newdt = ds.Tables["Table"].Clone();//克隆表 foreach (DataRow drItem in ds.Tables["Table"].Rows) { if (!string.IsNullOrWhiteSpace(drItem[0].ToString()) && !string.IsNullOrWhiteSpace(drItem[1].ToString()) && !string.IsNullOrWhiteSpace(drItem[2].ToString()) && !string.IsNullOrWhiteSpace(drItem[3].ToString()) && !string.IsNullOrWhiteSpace(drItem[4].ToString()) && !string.IsNullOrWhiteSpace(drItem[5].ToString()) && !string.IsNullOrWhiteSpace(drItem[6].ToString())) { newdt.Rows.Add(drItem.ItemArray); } } ds.Tables.Remove("Table"); newdt.TableName = "Table"; ds.Tables.Add(newdt); return ds.Tables[0];
标签:
原文地址:http://www.cnblogs.com/myblogslh/p/4486328.html