gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 01:23:28 26 4
gpt4 key购买 nike

我正在使用数据库中的数据填充模板 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com