From 70bebd4ef86ed4d695b8b202c5cff0c212140d01 Mon Sep 17 00:00:00 2001 From: Joern Muehlencord Date: Sun, 17 Feb 2019 17:45:56 +0100 Subject: [PATCH] hide comments by default --- .../main/java/de/muehlencord/shared/poi/PoiUtil.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/poi-util/src/main/java/de/muehlencord/shared/poi/PoiUtil.java b/poi-util/src/main/java/de/muehlencord/shared/poi/PoiUtil.java index 08c92ad..cfe42a2 100644 --- a/poi-util/src/main/java/de/muehlencord/shared/poi/PoiUtil.java +++ b/poi-util/src/main/java/de/muehlencord/shared/poi/PoiUtil.java @@ -82,6 +82,10 @@ public abstract class PoiUtil { } public static void addCellComment(XSSFWorkbook wb, Row row, int cellNumber, String cellComment, int rowCount, int columnCount) { + addCellComment(wb, row, cellNumber, cellComment, rowCount, columnCount, false); + } + + public static void addCellComment(XSSFWorkbook wb, Row row, int cellNumber, String cellComment, int rowCount, int columnCount, boolean commentVisible) { Drawing drawing = row.getSheet().createDrawingPatriarch(); CreationHelper factory = wb.getCreationHelper(); @@ -99,9 +103,11 @@ public abstract class PoiUtil { RichTextString str = factory.createRichTextString(cellComment); comment.setString(str); comment.setAuthor("PCD"); + comment.setVisible(commentVisible); // Assign the comment to the cell cell.setCellComment(comment); + } public static void setDateValue(Row row, int cellNumber, Date date, CellStyle cellStyle) { @@ -233,7 +239,9 @@ public abstract class PoiUtil { } /** - * remove charecters which often cause troubles in other applications - e.g. em dash (long dash) is created by Excel automatically + * remove charecters which often cause troubles in other applications - e.g. em dash (long dash) is created by Excel + * automatically + * * @param sourceValue the input string to execute the replacement * @return sourceValue with replaced characters */