I am generating an excel file (.xlsx) using SXSSFWorkbook (stream) with 1 million rows. One column has to contain a dropdown with 4-5 values. I am able to generate this but I have two problems-
- The excel is taking lot of time to generate. 7 minutes with dropdown and 11 seconds without for 250,000 rows.
- Unable to open the file once it is generated as it is asking to recover the data which will fail eventually. The message says "Errors were detected in file D:\Test.xlsx Removed Feature: Data validation from /xl/worksheets/sheet2.xml part"
The below is the code snippet
DataValidationHelper validationHelper = sh.getDataValidationHelper();
CellRangeAddressList addressList = new CellRangeAddressList(0, sh.getLastRowNum(), cellnum, cellnum);
DataValidationConstraint constraint = validationHelper.createExplicitListConstraint(new String[] { "High risk", "Medium risk", "Low risk", "No risk" });
DataValidation dataValidation = validationHelper.createValidation(constraint, addressList);
dataValidation.setSuppressDropDownArrow(true);
sh.addValidationData(dataValidation);
Please suggest me better solutions.