java - 如何使用 Java Apache POI 在 Excel 工作表中隐藏以下未使用的行?

标签 java excel apache-poi rows

我正在使用数据库中的数据填充模板 Excel 工作表:

 for (Map<String, Object> resultRow : dbResults) {
        if ((currentRow = sheet.getRow(currentDataRow)) == null) {
            currentRow = sheet.createRow(currentDataRow);   // Creates a new row.
        }
        //currentRow.getRowStyle().setHidden(false);

        for (int i = 0; i < resultColumns; i++) {
            currentCell = currentRow.getCell(i, Row.CREATE_NULL_AS_BLANK);
            setCellValue(currentCell, resultRow.get(dbcolumnNames[i]));
        }
        currentDataRow += 1;
    }

// How to hide all empty/Un-used rows following currentDataRow ?

目标实现:

  • I want that the Un-Used rows following the populated rows should be hidden ?
  • All Populated rows must be visible.
  • Eg: If 1st 100 data rows are filled, then rows following 101 and onward should be hidden.

请帮忙!!

最佳答案

Row r = sheet.getRow(indexRow);
if ( r!=null ) {
    r.setZeroHeight(true);
}

关于java - 如何使用 Java Apache POI 在 Excel 工作表中隐藏以下未使用的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6931633/

相关文章:

java - 从 View 条目获取 Notes 日期时间到 JAVA 日期

java - 单词数组,然后嵌套 for 循环来检查字符

python - 更改 pandas 中数据框的堆叠

java - 如何使用 POI + Java 获取数据透视表最后填充行号。 -版本 3.12.x

java - 从 Docx 中删除内容控件

java - 如何在 while 循环中更新 jLabel

java - 如何使用 Java 将一组对象移动到 ArrayList 内的不同位置?

java - 如何使用库“ Material 日历 View ”保存用户每天在EditText中输入的内容?

javascript - 更改 xlsl 工作表中的单元格值,同时保持 nodejs 格式

.net - 有没有办法以编程方式连接 Excel 文件?