From 9cde034ab97f4fc512682f3320300d9b55f48095 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sat, 22 Jun 2019 06:12:19 +0000 Subject: [PATCH] Bug 62906 and 63401: Ensure tables have an initial name which does not conflict with existing names git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1861819 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/xssf/usermodel/XSSFSheet.java | 18 ++++++++-- .../apache/poi/xssf/usermodel/XSSFTable.java | 2 +- .../poi/xssf/usermodel/TestXSSFTable.java | 35 +++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index f897d80547..f23e31c477 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -4097,6 +4097,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { /** * Creates a new Table, and associates it with this Sheet. + *

+ * The table is assigned a default display name (since 4.1.1) which can be overridden + * by calling {@code setDisplayName}. The default display name is guaranteed to not conflict + * with the names of any {@code XSSFName} or {@code XSSFTable} in the workbook. * * @param tableArea * the area that the table should cover, should not be null @@ -4140,9 +4144,17 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { table.setArea(tableArea); } - // Bug 62906: Must set a display name; can be overridden using setDisplayName - final String displayName = "Table" + tableNumber; - table.setDisplayName(displayName); + // Set the default name of the table. This must not conflict with any defined names. + while(tableNumber