如何使用closedxml在excel中查找空行 [英] How to find empty rows in excel using closedxml

查看:253
本文介绍了如何使用closedxml在excel中查找空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在封闭的xml中查找和删除空行



我尝试过:



how to find and remove empty rows in closed xml

What I have tried:

<pre>foreach (IXLRow theRow in theworksheet.Rows())
                    {
                        int row = theworksheet.LastRowUsed().RowNumber();
                        if (firstRow)
                        {
                            int cells = 0;
                            foreach (IXLCell cell in theRow.Cells())
                            {
                                cells++;

                                if (cells > 27)
                                {
                                    break;
                                }
                                else
                                {
                                    dt3.Columns.Add(cell.Value.ToString());
                                }
                            }
                            firstRow = false;
                        }

推荐答案

Quote:

如何在封闭的xml中查找和删除空行

how to find and remove empty rows in closed xml



尝试


try

int lastrow  = ws.LastRowUsed().RowNumber();
            var rows = ws.Rows(1, lastrow);
            foreach (IXLRow row in rows)
            {
                if (row.IsEmpty())
                    row.Delete();
            }



参考 ClosedXML - 文档 [ ^ ]


这篇关于如何使用closedxml在excel中查找空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆