diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java index fd153a77a..e1afacbc5 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java @@ -313,6 +313,39 @@ public final class TestXSSFComment extends BaseTestCellComment { } } + @Test + public void testBug55814() throws IOException { + try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("55814.xlsx")) { + + int oldsheetIndex = wb.getSheetIndex("example"); + Sheet oldsheet = wb.getSheetAt(oldsheetIndex); + + Comment comment = oldsheet.getRow(0).getCell(0).getCellComment(); + assertEquals("Comment Here\n", comment.getString().getString()); + + Sheet newsheet = wb.cloneSheet(oldsheetIndex); + + wb.removeSheetAt(oldsheetIndex); + + //wb.write(new FileOutputStream("/tmp/outnocomment.xlsx")); + + comment = newsheet.getRow(0).getCell(0).getCellComment(); + assertNotNull("Should have a comment on A1 in the new sheet", comment); + assertEquals("Comment Here\n", comment.getString().getString()); + + Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb); + assertNotNull(wbBack); + wbBack.close(); + } + + try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("55814.xlsx")) { + int oldsheetIndex = wb.getSheetIndex("example"); + Sheet newsheet = wb.getSheetAt(oldsheetIndex); + Comment comment = newsheet.getRow(0).getCell(0).getCellComment(); + assertEquals("Comment Here\n", comment.getString().getString()); + } + } + @Test public void bug57838DeleteRowsWthCommentsBug() throws IOException { Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57838.xlsx"); diff --git a/test-data/spreadsheet/55814.xlsx b/test-data/spreadsheet/55814.xlsx new file mode 100644 index 000000000..ae6d9eccd Binary files /dev/null and b/test-data/spreadsheet/55814.xlsx differ