'is it possible to let List validation not set value when using poi to export to excel
I am using poi poi-ooxml-4.0.0 to export an excel in the spring boot java project, but shows error:
Caused by: java.lang.IllegalArgumentException: List validation with explicit values must specify at least one value
at org.apache.poi.xssf.usermodel.XSSFDataValidationConstraint.<init>(XSSFDataValidationConstraint.java:50) ~[poi-ooxml-4.0.0.jar!/:4.0.0]
at org.apache.poi.xssf.usermodel.XSSFDataValidationHelper.createExplicitListConstraint(XSSFDataValidationHelper.java:66) ~[poi-ooxml-4.0.0.jar!/:4.0.0]
at com.sportswin.soa.zhuolianorg.repo.DataValidationHandler.lambda$afterSheetCreate$3(DataValidationHandler.java:67) ~[classes!/:na]
at java.util.HashMap.forEach(HashMap.java:1289) ~[na:1.8.0_252]
at com.sportswin.soa.zhuolianorg.repo.DataValidationHandler.afterSheetCreate(DataValidationHandler.java:61) ~[classes!/:na]
at com.alibaba.excel.util.WriteHandlerUtils.afterSheetCreate(WriteHandlerUtils.java:103) ~[easyexcel-2.2.11.jar!/:na]
at com.alibaba.excel.util.WriteHandlerUtils.afterSheetCreate(WriteHandlerUtils.java:93) ~[easyexcel-2.2.11.jar!/:na]
at com.alibaba.excel.context.WriteContextImpl.initSheet(WriteContextImpl.java:188) ~[easyexcel-2.2.11.jar!/:na]
at com.alibaba.excel.context.WriteContextImpl.currentSheet(WriteContextImpl.java:122) ~[easyexcel-2.2.11.jar!/:na]
at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:53) ~[easyexcel-2.2.11.jar!/:na]
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:161) ~[easyexcel-2.2.11.jar!/:na]
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:146) ~[easyexcel-2.2.11.jar!/:na]
at com.sportswin.soa.zhuolianorg.repo.UploadSparkUserDAO.addRemark(UploadSparkUserDAO.java:103) ~[classes!/:na]
the error is clear that tell me the List validation column value must set, but sometimes the data validation column did not have data, is it possible to output the excel without default value? like this:
Solution 1:[1]
Because you did not show your code, as the comment said,check your listOfValues is null or the size is 0. The error message is clear, you could not pass null to the listOfValues. I predicate you generate the validation from some source of data in your code. So check the error columns data is null or not. That's the problem happens, you should make sure all your validation column have at least one choice.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dolphin |

