From 5eaa0acfbbfc2e62c9bd81f5088246d9f72ffc1d Mon Sep 17 00:00:00 2001 From: Anton Oellerer Date: Mon, 17 Oct 2022 10:37:36 +0200 Subject: [PATCH 1/3] Resolve UUID to `ScalarPlaceholder` To be able to simply represent UUIDs, when resolving one, a `ScalarPlaceholder` containing its string representation is returned. --- build.gradle | 2 +- .../docutools/jocument/impl/ReflectionResolver.java | 3 +++ .../docutools/jocument/ReflectionResolvingTests.java | 10 ++++++++++ .../com/docutools/jocument/sample/model/Person.java | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 06972b55..e44454a8 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group 'com.docutools' -version = '1.5.7-alpha.1' +version = '1.5.8-alpha.2' sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 diff --git a/src/main/java/com/docutools/jocument/impl/ReflectionResolver.java b/src/main/java/com/docutools/jocument/impl/ReflectionResolver.java index e55f5db4..58e77f63 100644 --- a/src/main/java/com/docutools/jocument/impl/ReflectionResolver.java +++ b/src/main/java/com/docutools/jocument/impl/ReflectionResolver.java @@ -35,6 +35,7 @@ import java.util.List; import java.util.Locale; import java.util.Optional; +import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -401,6 +402,8 @@ private Optional resolveSimplePlaceholder(Object property, Stri } else if (property instanceof Path path && isFieldAnnotatedWith(bean.getClass(), placeholderName, Image.class)) { return ReflectionUtils.findFieldAnnotation(bean.getClass(), placeholderName, Image.class) .map(image -> new ImagePlaceholderData(path).withMaxWidth(image.maxWidth())); + } else if (property instanceof UUID uuid) { + return Optional.of(new ScalarPlaceholderData<>(uuid.toString())); } else { return Optional.empty(); } diff --git a/src/test/java/com/docutools/jocument/ReflectionResolvingTests.java b/src/test/java/com/docutools/jocument/ReflectionResolvingTests.java index aa5a42b9..ce64e9ca 100644 --- a/src/test/java/com/docutools/jocument/ReflectionResolvingTests.java +++ b/src/test/java/com/docutools/jocument/ReflectionResolvingTests.java @@ -274,4 +274,14 @@ void shouldTranslateShipName() { assertThat(shipName.get().toString(), equalTo("VSS Unternehmung")); } + + @Test + void shouldResolveUUIDtoString() { + Person picardPerson = SampleModelData.PICARD_PERSON; + var resolver = new ReflectionResolver(picardPerson); + + var id = resolver.resolve("id"); + + assertThat(id.get().toString(), equalTo(picardPerson.getId().toString())); + } } diff --git a/src/test/java/com/docutools/jocument/sample/model/Person.java b/src/test/java/com/docutools/jocument/sample/model/Person.java index c7e4d937..a0a51e85 100644 --- a/src/test/java/com/docutools/jocument/sample/model/Person.java +++ b/src/test/java/com/docutools/jocument/sample/model/Person.java @@ -6,8 +6,10 @@ import java.time.LocalDate; import java.time.Period; import java.time.ZoneOffset; +import java.util.UUID; public class Person { + private final UUID id = UUID.randomUUID(); private final String firstName; private final String lastName; @@ -55,4 +57,8 @@ public void setFavouriteShip(Ship favouriteShip) { public Ship getFavouriteShip() { return favouriteShip; } + + public UUID getId() { + return id; + } } From 2aebb0d2454de2039d348c3e6a890e7d65a4b81a Mon Sep 17 00:00:00 2001 From: Anton Oellerer Date: Wed, 19 Oct 2022 11:03:01 +0200 Subject: [PATCH 2/3] Fix xlsx formatting There were a couple of bugs in the xlsx formatting code where style information was copied incorrectly from a row/cell to the new object. Additionally, default column style are now set as well. To verify the behaviour, a test for manual verification has been added to `ExcelDocuments.java` --- build.gradle | 2 +- .../excel/implementations/SXSSFWriter.java | 59 +++++++++++++++--- .../jocument/excel/ExcelDocuments.java | 20 +++++- .../templates/excel/ComplexFormatting.xlsx | Bin 0 -> 28228 bytes 4 files changed, 70 insertions(+), 11 deletions(-) create mode 100755 src/test/resources/templates/excel/ComplexFormatting.xlsx diff --git a/build.gradle b/build.gradle index e44454a8..cd805b89 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group 'com.docutools' -version = '1.5.8-alpha.2' +version = '1.5.9-alpha.1' sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 diff --git a/src/main/java/com/docutools/jocument/impl/excel/implementations/SXSSFWriter.java b/src/main/java/com/docutools/jocument/impl/excel/implementations/SXSSFWriter.java index 3e587a73..58bbbb3a 100644 --- a/src/main/java/com/docutools/jocument/impl/excel/implementations/SXSSFWriter.java +++ b/src/main/java/com/docutools/jocument/impl/excel/implementations/SXSSFWriter.java @@ -45,10 +45,13 @@ public class SXSSFWriter implements ExcelWriter { /** * Maps the {@link CellStyle} objects of the old workbook to the new ones. */ - private final Map styleStyleMapping = new HashMap<>(); + private final Map cellStyleMap = new HashMap<>(); private Sheet currentSheet; + private Sheet templateSheet; private Row currentRow; private int rowOffset = 0; + private int leftMostColumn = -1; + private int rightMostColumn = -1; /** * Creates a new SXSSFWriter. @@ -102,6 +105,7 @@ private static void transferPicture(XSSFShape shape, SXSSFSheet newSheet) { @Override public void newSheet(Sheet sheet) { logger.info("Creating new sheet of {}", sheet.getSheetName()); + templateSheet = sheet; currentSheet = workbook.createSheet(sheet.getSheetName()); currentSheet.setActiveCell(sheet.getActiveCell()); currentSheet.setAutobreaks(sheet.getAutobreaks()); @@ -139,19 +143,55 @@ public void newRow(Row row) { logger.debug("Creating new row {}", row.getRowNum()); currentRow = currentSheet.createRow(row.getRowNum() + rowOffset); currentRow.setHeight(row.getHeight()); - currentRow.setRowStyle(row.getRowStyle()); + if (row.isFormatted()) { + currentRow.setRowStyle(cellStyleMap.computeIfAbsent((int) row.getRowStyle().getIndex(), i -> copyCellStyle(row.getRowStyle()))); + } currentRow.setZeroHeight(row.getZeroHeight()); + updateColumnStyles(row); + } + + private void updateColumnStyles(Row row) { + if (rightMostColumn == -1 || leftMostColumn == -1) { + setup(row); + } + if (row.getLastCellNum() > rightMostColumn) { + for (; rightMostColumn < row.getLastCellNum(); rightMostColumn++) { + copyColumnStyle(rightMostColumn); + } + logger.debug("Rightmost column: {}", rightMostColumn); + } + if (row.getFirstCellNum() < leftMostColumn) { + for (; leftMostColumn > row.getLastCellNum(); leftMostColumn--) { + copyColumnStyle(leftMostColumn); + } + logger.debug("Leftmost column: {}", leftMostColumn); + } + } + + private void setup(Row row) { + leftMostColumn = row.getFirstCellNum(); + rightMostColumn = row.getLastCellNum(); + logger.debug("Rightmost column: {}", rightMostColumn); + logger.debug("Leftmost column: {}", leftMostColumn); + for (int i = leftMostColumn; i < rightMostColumn; i++) { + copyColumnStyle(i); + } + } + + private void copyColumnStyle(int rightMostColumn) { + CellStyle columnStyle = templateSheet.getColumnStyle(rightMostColumn); + if (columnStyle != null) { + currentSheet.setDefaultColumnStyle(rightMostColumn, + cellStyleMap.computeIfAbsent((int) columnStyle.getIndex(), i -> copyCellStyle(columnStyle))); + } } @Override public void addCell(Cell cell) { - logger.debug("Creating new cell {} {}", cell.getColumnIndex(), cell.getRow().getRowNum()); + logger.trace("Creating new cell {} {}", cell.getColumnIndex(), cell.getRow().getRowNum()); var newCell = currentRow.createCell(cell.getColumnIndex(), cell.getCellType()); - if (workbook.getCellStyleAt(cell.getCellStyle().getIndex()) == null) { - copyCellStyle(cell.getCellStyle()); - } newCell.setCellComment(cell.getCellComment()); - newCell.setCellStyle(cell.getCellStyle()); + newCell.setCellStyle(cellStyleMap.computeIfAbsent((int) cell.getCellStyle().getIndex(), i -> copyCellStyle(cell.getCellStyle()))); newCell.setHyperlink(cell.getHyperlink()); currentSheet.setColumnWidth(cell.getColumnIndex(), cell.getSheet().getColumnWidth(cell.getColumnIndex())); switch (cell.getCellType()) { @@ -162,6 +202,7 @@ public void addCell(Cell cell) { case BOOLEAN -> newCell.setCellValue(cell.getBooleanCellValue()); case ERROR -> newCell.setCellErrorValue(cell.getErrorCellValue()); default -> { + // do nothing } } if (cell.getHyperlink() != null) { @@ -180,11 +221,11 @@ public void addCell(Cell templateCell, String newCellText) { @Override public void addCell(Cell templateCell, String newCellText, int columnOffset) { - logger.debug("Creating new cell {} {} with text {}", + logger.trace("Creating new cell {} {} with text {}", templateCell.getColumnIndex(), templateCell.getRow().getRowNum(), newCellText); var newCell = currentRow.createCell(templateCell.getColumnIndex() + columnOffset, templateCell.getCellType()); newCell.setCellComment(templateCell.getCellComment()); - newCell.setCellStyle(styleStyleMapping.computeIfAbsent(templateCell.getCellStyle(), this::copyCellStyle)); + newCell.setCellStyle(cellStyleMap.computeIfAbsent((int) templateCell.getCellStyle().getIndex(), i -> copyCellStyle(templateCell.getCellStyle()))); newCell.setHyperlink(templateCell.getHyperlink()); currentSheet.setColumnWidth(templateCell.getColumnIndex(), templateCell.getSheet().getColumnWidth(templateCell.getColumnIndex())); if (templateCell.getCellType() == CellType.FORMULA) { diff --git a/src/test/java/com/docutools/jocument/excel/ExcelDocuments.java b/src/test/java/com/docutools/jocument/excel/ExcelDocuments.java index 42a29a58..906b333a 100644 --- a/src/test/java/com/docutools/jocument/excel/ExcelDocuments.java +++ b/src/test/java/com/docutools/jocument/excel/ExcelDocuments.java @@ -130,7 +130,25 @@ void shouldResolveNestedLoops() throws InterruptedException, IOException { void inherti() throws InterruptedException, IOException { // Arrange Template template = Template.fromClassPath("/templates/excel/Formatting.xlsx") - .orElseThrow(); + .orElseThrow(); + PlaceholderResolver resolver = new ReflectionResolver(SampleModelData.PICARD); + + // Act + Document document = template.startGeneration(resolver); + document.blockUntilCompletion(60000L); // 1 minute + + // Assert + assertThat(document.completed(), is(true)); + + Desktop.getDesktop().open(document.getPath().toFile()); + } + + @Test + @DisplayName("Inherit style from source excel.") + void inheritStylePerCell() throws InterruptedException, IOException { + // Arrange + Template template = Template.fromClassPath("/templates/excel/ComplexFormatting.xlsx") + .orElseThrow(); PlaceholderResolver resolver = new ReflectionResolver(SampleModelData.PICARD); // Act diff --git a/src/test/resources/templates/excel/ComplexFormatting.xlsx b/src/test/resources/templates/excel/ComplexFormatting.xlsx new file mode 100755 index 0000000000000000000000000000000000000000..61a6a78da7cab925f15383e4ebe80c58eb7d7dc8 GIT binary patch literal 28228 zcmeHw2{@G9`#%+BiIS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2F=FG7DxiKRs#m9~)KSZ=Hx7`ZVr398fSm?5$%a)_76_ zPtZVgS2Kw4Wc0}(%CT#ta8zk`cOyd!hV?TUYkv}WkmWx%&g_!Sfa8l=%({=$k35lV z&di7mKa#!LX2P=EsW7#y2SfBdH$qW?yXu5=Fi$i!PWA>qbI`>}9H2;ilpN_=kKu3h zV@wuGJG!F9l3p{v5?&)=HO(QbNkp*%2AbujD#?nXm$!})2hs>ltyBbK>fyzjwIy2o94Z7>u?oWzn}H z%7&B&;N?BzM^K*O83dd;B^ISTeB>kiWF9Mr)^p@w$Te6KLnNt;YQ4#C{X{KUN-VR7 zaVLqog+2aaa*~cePz9GR8#<|*+w=5=PKX|?CY~CZ&pwwqIWr}4?qPLK6YZEgl zItj4@)i3D2gZQ)Im%lQ@aR*~iD9S4AbA1cTa(s0*`rziF*hW}VYtop{bvly~?LY31 z_V+Jt#c$F-!5SuIP$}?1X%;dYr=v?Fpohnry-0q|I=FX{ZuIp8H2Hm%TP=YxR2{4j zCt^EZkNVxjuWiI9(gi2KR0YyP*x0UdHuTwRfmd-8T(%q>?==^J&t7vb5a#%PwAS3y zq@bg>;{*k~@z|CKLRQ+cHb5-?6Aqoin+$-O|^u1>{7x+pz2L~Vc^B!o8 Jtq1he{{f Date: Mon, 12 Dec 2022 14:18:24 +0100 Subject: [PATCH 3/3] Add comments --- .../jocument/impl/excel/implementations/SXSSFWriter.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/docutools/jocument/impl/excel/implementations/SXSSFWriter.java b/src/main/java/com/docutools/jocument/impl/excel/implementations/SXSSFWriter.java index 58bbbb3a..9edf8108 100644 --- a/src/main/java/com/docutools/jocument/impl/excel/implementations/SXSSFWriter.java +++ b/src/main/java/com/docutools/jocument/impl/excel/implementations/SXSSFWriter.java @@ -150,6 +150,15 @@ public void newRow(Row row) { updateColumnStyles(row); } + /** + * Set the style of the columns accessed in this row. + * + *

Since apache POI does not have a global `leftMostColumn` and `rightMostColumn`, it is not possible to copy the default styles of each column + * at the start of the report generation. Due to this, on each new row we check whether it accesses columns for which the default column style has + * not been set yet, and copies the style to the new document. + * + * @param row The row to check for border column accesses + */ private void updateColumnStyles(Row row) { if (rightMostColumn == -1 || leftMostColumn == -1) { setup(row);