From 9bb66bd3c782c6a2b3123fecb4ea9eadd7044627 Mon Sep 17 00:00:00 2001 From: Felipe Lang Date: Mon, 15 Jan 2024 13:48:46 -0300 Subject: [PATCH] fix: reuse cell style Close #87 --- .../addons/gridexporter/ExcelInputStreamFactory.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelInputStreamFactory.java b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelInputStreamFactory.java index 8a39829..8150386 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelInputStreamFactory.java +++ b/src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelInputStreamFactory.java @@ -274,9 +274,7 @@ private void buildRow(T item, Sheet sheet, Cell startingCell) { Cell currentCell = startingCell; if (startingCell.getColumnIndex() < currentColumn[0]) { currentCell = startingCell.getRow().createCell(currentColumn[0]); - CellStyle newCellStyle = currentCell.getSheet().getWorkbook().createCellStyle(); - newCellStyle.cloneStyleFrom(startingCell.getCellStyle()); - currentCell.setCellStyle(newCellStyle); + currentCell.setCellStyle(startingCell.getCellStyle()); configureAlignment(column.getTextAlign(), currentCell); } @@ -402,9 +400,7 @@ private void fillHeaderOrFooter( sheet .getRow(sheet.getActiveCell().getRow()) .createCell(sheet.getActiveCell().getColumn()); - CellStyle newCellStyle = cell.getSheet().getWorkbook().createCellStyle(); - newCellStyle.cloneStyleFrom(style); - cell.setCellStyle(newCellStyle); + cell.setCellStyle(style); } Object value = (isHeader