Apache Poi excel删除空行 [英] Apache Poi excel remove blank rows

查看:364
本文介绍了Apache Poi excel删除空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有3000行的excel文件。我删除了2000(与ms excel应用程序),但是当我从代码调用sheet.getLastRowNum(),它给我3000(而不是1000)..我如何删除空白行?



我尝试了代码从这里,但它不起作用。

解决方案

我发现任何解决方案如何轻松获得真正的行数,但我已经找到一个解决方案来删除这样的行,这可能对处理类似问题的人有用。见下文。



我搜索了一下,发现这个解决方案



它所做的是从底部删除可能完全符合您想要的空行。


I have an excel file with 3000 rows. I remove the 2000 (with ms excel app), but when i call the sheet.getLastRowNum() from code , it gives me 3000 (instead of 1000).. How can i remove the blank rows?

I tried the code from here but it doesn't works....

解决方案

I haven't found any solution on how to easily get the "real" number of rows but I've found a solution to remove such rows which might be useful to someone who's tackling similar issue. See bellow.

I've searched a bit and found this solution

All it does is it deletes those empty rows from the bottom which might be exactly what you want.

这篇关于Apache Poi excel删除空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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