C#读取Excel表格去掉空行
生活随笔
收集整理的這篇文章主要介紹了
C#读取Excel表格去掉空行
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
去掉空行代碼:
protected DataTable RemoveEmpty(DataTable dt) {List<DataRow> removelist = new List<DataRow>();for (int i = 0; i < dt.Rows.Count; i++){bool rowdataisnull = true;for (int j = 0; j < dt.Columns.Count; j++){if (!string.IsNullOrEmpty(dt.Rows[i][j].ToString().Trim())){rowdataisnull = false;}}if (rowdataisnull){removelist.Add(dt.Rows[i]);}}//移除空行for (int i = 0; i < removelist.Count; i++){dt.Rows.Remove(removelist[i]);}return dt; }?
總結
以上是生活随笔為你收集整理的C#读取Excel表格去掉空行的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 多表查询 优化_MySql多
- 下一篇: Python3 - 深入学习Docker