From 68405a28f26b2d502231090418c4ac5f00160794 Mon Sep 17 00:00:00 2001 From: Frank Weinberg Date: Sun, 18 Sep 2022 20:17:01 +0200 Subject: [PATCH] properly handle cells with existing comments on xlsx export --- .../scoreboard/utils/StatsbookExporter.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/com/carolinarollergirls/scoreboard/utils/StatsbookExporter.java b/src/com/carolinarollergirls/scoreboard/utils/StatsbookExporter.java index 7b243796..3cd94ce2 100644 --- a/src/com/carolinarollergirls/scoreboard/utils/StatsbookExporter.java +++ b/src/com/carolinarollergirls/scoreboard/utils/StatsbookExporter.java @@ -654,14 +654,20 @@ private static void setComment(Cell cell, String text) { Row row = cell.getRow(); Sheet sheet = row.getSheet(); CreationHelper factory = sheet.getWorkbook().getCreationHelper(); - Drawing drawing = sheet.createDrawingPatriarch(); - - ClientAnchor anchor = factory.createClientAnchor(); - anchor.setCol1(cell.getColumnIndex()); - anchor.setCol2(cell.getColumnIndex() + 2); - anchor.setRow1(row.getRowNum()); - anchor.setRow2(row.getRowNum() + 3); - Comment comment = drawing.createCellComment(anchor); + + Comment comment = cell.getCellComment(); + + if (comment == null) { + Drawing drawing = sheet.createDrawingPatriarch(); + + ClientAnchor anchor = factory.createClientAnchor(); + anchor.setCol1(cell.getColumnIndex()); + anchor.setCol2(cell.getColumnIndex() + 2); + anchor.setRow1(row.getRowNum()); + anchor.setRow2(row.getRowNum() + 3); + comment = drawing.createCellComment(anchor); + } + RichTextString str = factory.createRichTextString(text); comment.setString(str); comment.setAuthor("CRG");