简体   繁体   English

如何使用EPPlus Excel Package Plus删除空白行

[英]How to remove Blank Rows using EPPlus Excel Package Plus

I'm using EPPlus 4.1.0.0, and I want to convert my excel sheet into a datatable. 我正在使用EPPlus 4.1.0.0,并且要将Excel工作表转换为数据表。

There are few empty rows at the end of the excel file. excel文件末尾的空白行很少。

So while converting it, I am also getting the empty rows into datatable. 因此,在转换时,我还将空行放入数据表中。

How do I remove the empty rows before converting it to a datatable? 如何在将空行转换为数据表之前将其删除?

Maybe check my answer here: https://stackoverflow.com/a/49232456/1114531 也许在这里检查我的答案: https : //stackoverflow.com/a/49232456/1114531

It is checking the last row if it is empty and if yes it deletes it and doing this until finds non-empty row. 它正在检查最后一行是否为空,如果是,它将删除该行,直到找到非空行为止。 (non-empty means here: all columns in this row have some value) (此处非空表示:该行中的所有列均具有某些值)

您可以使用DeleteRow

 worksheet.DeleteRow(lastRow + 1, worksheet.Dimension.End.Row - lastRow - 1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM