【发布时间】:2012-05-10 08:09:54
【问题描述】:
我们正在使用 apache poi 3.8 来解析 Excel。我们需要能够检测(并跳过)隐藏行,因为它们在我们的用例中往往包含垃圾数据。
这看起来应该可行:
row.isFormatted() && row.getRowStyle().getHidden()
但似乎从来没有任何行级格式(getRowStyle() 总是返回 null)。作为最后的手段,我们认为检查单元格样式可能会起作用:
for (int i = 0; i < row.getLastCellNum(); i++) {
Cell cell = row.getCell(i);
if (cell != null && cell.getCellStyle() != null && cell.getCellStyle().getHidden())
...
但是对于我们得到的每一行(上面 for 循环中的自定义输出):
Cell 0 is not hidden org.apache.poi.hssf.usermodel.HSSFCellStyle@1b9142d0 / false
“getHidden()”是不起作用还是不像我认为的那样起作用?还有另一种检测隐藏行的方法吗? (隐藏的列也是一个不错的奖励,但相关性略低)
【问题讨论】:
标签: java apache excel apache-poi