diff options
author | Dominik Stadler <centic@apache.org> | 2021-01-01 15:51:19 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2021-01-01 15:51:19 +0000 |
commit | 685af351d1bfc2912584de1af4cc5eab4fe6b87c (patch) | |
tree | 1d5fad586c6f8d7316d91ec2a2fd39943febfd9d | |
parent | e4b70720be1a5a56f9c0205d7961543c71af0829 (diff) | |
download | poi-685af351d1bfc2912584de1af4cc5eab4fe6b87c.tar.gz poi-685af351d1bfc2912584de1af4cc5eab4fe6b87c.zip |
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
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java | 4 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java | 8 | ||||
-rw-r--r-- | test-data/spreadsheet/64750.xlsx | bin | 0 -> 12921 bytes |
3 files changed, 10 insertions, 2 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 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<XSSFDataValidation> getDataValidations() { List<XSSFDataValidation> 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 Binary files differnew file mode 100644 index 0000000000..7653dfe111 --- /dev/null +++ b/test-data/spreadsheet/64750.xlsx |