]> source.dussan.org Git - poi.git/commitdiff
[bug-66211] add test case
authorPJ Fanning <fanningpj@apache.org>
Sat, 13 Aug 2022 15:09:18 +0000 (15:09 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sat, 13 Aug 2022 15:09:18 +0000 (15:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903393 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFTable.java
test-data/spreadsheet/table-sample.xlsx [new file with mode: 0644]

index c09849d2f31b25491364209af0b8e545486b5a20..20aa24bb93eac381f255989c024f5dc8074cc4d1 100644 (file)
@@ -703,4 +703,27 @@ public final class TestXSSFTable {
             }
         }
     }
+
+    @Test
+    void bug66211() throws IOException {
+        try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("table-sample.xlsx")) {
+            XSSFTable table = wb.getTable("Tabelle1");
+            assertEquals(1, table.getHeaderRowCount());
+            assertEquals(3, table.getStartRowIndex());
+            List<XSSFTableColumn> cols = table.getColumns();
+            assertEquals(5, cols.size());
+            assertEquals("Field 1", cols.get(0).getName());
+            XSSFSheet sheet = table.getXSSFSheet();
+            XSSFRow headerRow = sheet.getRow(3);
+            headerRow.getCell(2).setCellValue("Column 1");
+            table.updateHeaders();
+            List<XSSFTableColumn> updatedCols = table.getColumns();
+            assertEquals(5, updatedCols.size());
+            assertEquals("Column 1", updatedCols.get(0).getName());
+            assertEquals(cols.get(1).getName(), updatedCols.get(1).getName());
+            assertEquals(cols.get(2).getName(), updatedCols.get(2).getName());
+            assertEquals(cols.get(3).getName(), updatedCols.get(3).getName());
+            assertEquals(cols.get(4).getName(), updatedCols.get(4).getName());
+        }
+    }
 }
diff --git a/test-data/spreadsheet/table-sample.xlsx b/test-data/spreadsheet/table-sample.xlsx
new file mode 100644 (file)
index 0000000..b2a1aa8
Binary files /dev/null and b/test-data/spreadsheet/table-sample.xlsx differ