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