From 685af351d1bfc2912584de1af4cc5eab4fe6b87c Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Fri, 1 Jan 2021 15:51:19 +0000 Subject: [PATCH] Bug 64750: Do not use CTDataValidations.getCount(), instead only rely on getDataValidationArray Field "count" seems to be optional according to the schema, so by using only the array Apache POI can read data validations from workbooks that do not populate the "count" field properly. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885011 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/xssf/usermodel/XSSFSheet.java | 4 ++-- .../apache/poi/xssf/usermodel/TestXSSFBugs.java | 8 ++++++++ test-data/spreadsheet/64750.xlsx | Bin 0 -> 12921 bytes 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 test-data/spreadsheet/64750.xlsx 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 6f8613afa6..abaca3a5cf 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -80,7 +80,6 @@ import org.apache.poi.util.Beta; import org.apache.poi.util.Internal; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; -import org.apache.poi.util.Removal; import org.apache.poi.util.Units; import org.apache.poi.xssf.model.CommentsTable; import org.apache.poi.xssf.usermodel.XSSFPivotTable.PivotTableReferenceConfigurator; @@ -4011,7 +4010,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { public List getDataValidations() { List xssfValidations = new ArrayList<>(); CTDataValidations dataValidations = this.worksheet.getDataValidations(); - if( dataValidations!=null && dataValidations.getCount() > 0 ) { + if (dataValidations != null) { for (CTDataValidation ctDataValidation : dataValidations.getDataValidationArray()) { CellRangeAddressList addressList = new CellRangeAddressList(); @@ -4031,6 +4030,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { xssfValidations.add(xssfDataValidation); } } + return xssfValidations; } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 5476e28688..7c2fed7a83 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -3661,4 +3661,12 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { assertEquals(CellType.NUMERIC, value.getCellType()); assertEquals(1, value.getNumberValue(), 0.01); } + + @Test + public void test64750() throws IOException { + try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("64750.xlsx")) { + Sheet sheet = wb.getSheet("Sheet1"); + assertEquals(1, sheet.getDataValidations().size()); + } + } } diff --git a/test-data/spreadsheet/64750.xlsx b/test-data/spreadsheet/64750.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..7653dfe1118ac0a9906efd216d1b11ec6fb7f4f7 GIT binary patch literal 12921 zcmeI22Q-}B*7%jdV1gieZ%Nb%iC%)}okSnK_aJ&3H6e)>5-lPUf*?xtE~3sLf>8%U zMASrd!yj4qi{yQ8?!E7Q@BQCz-S1e7GkeY1&pz9E&e^|xwx$X;fE)t|1Y*$2@M&S3 zYE(ykA16L5cXMxh7h8|NbT0AwI6GzZL0nqEAiOoQC88UX_J&ksvg9Ux>R_TNb{E?C z*e;^%@t}TXL3@8p2Ip?6omH5NXT|n43$g&#Po<bi2aL;S?6TI9oPTFZ1wGkRq+s?JaX;c)SM#f&H z&`mBeB##Z4x_IxwW_)UD8`J0+HoMzkJJM+z-0=BZ6$URW2Ii?JSFG<(EH8iZ+kvg@ zqHU@rBsEG+izwR%78qCbh@(tx#{%}PYG9xI8pW1eVqJ^8(;lX%+qy{@1=X26)_8F^ z9WFTRE}zzRFtHcKr>-NJ4xgDH^t-h`7hqC65KxugfOJJR^n7kxv=^87u)MH?3_`pN zrr*D0CAO+D*>j0DSa>fsYd=^Z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