This is an automated email from the ASF dual-hosted git repository. centic pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/poi.git
commit 25a2dd9227d8e2d1e1818e324f720b15d3f36f1a Author: Dominik Stadler <[email protected]> AuthorDate: Mon Nov 3 07:03:31 2025 +0100 Adjust parsing XSSFBuiltinTableStyle In case of invalid enum-value keep the fallback-handling as before as otherwise some existing documents fail to parse --- .../java/org/apache/poi/xssf/model/StylesTable.java | 13 +++++++++---- test-data/spreadsheet/xssf-enum.xltx.xlsx | Bin 0 -> 13876 bytes 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java index 99a9e37756..abab993669 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java @@ -841,15 +841,20 @@ public class StylesTable extends POIXMLDocumentPart implements Styles { * @return defined style, either explicit or built-in, or null if not found * * @since 3.17 beta 1 - * @throws IllegalArgumentException if there is no explicit table style but the name is an * unknown built-in style */ public TableStyle getTableStyle(String name) { if (name == null) return null; TableStyle tableStyle = getExplicitTableStyle(name); - if (tableStyle == null) - tableStyle = XSSFBuiltinTableStyle.valueOf(name).getStyle(); - return tableStyle; + if (tableStyle != null) { + return tableStyle; + } + + try { + return XSSFBuiltinTableStyle.valueOf(name).getStyle(); + } catch (IllegalArgumentException e) { + return getExplicitTableStyle(name); + } } /** diff --git a/test-data/spreadsheet/xssf-enum.xltx.xlsx b/test-data/spreadsheet/xssf-enum.xltx.xlsx new file mode 100644 index 0000000000..24a2104473 Binary files /dev/null and b/test-data/spreadsheet/xssf-enum.xltx.xlsx differ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
