Reputation: 15090
I need to create Excel template from java. In that each cell should contain the dropdown values based on the header. These dropdowns and values will be populated from the java code.Please provide the sample code to create the Dropdowns. And how to insert values into dropdowns.I am using poi for creating the Excel.
Upvotes: 2
Views: 5209
Reputation: 15090
The below code sample gives the best resolution for my question.
CellRangeAddressList addressList = new CellRangeAddressList(0, 5, 0, 0);
DVConstraint dvConstraint = DVConstraint
.createExplicitListConstraint(new String[] { "10", "20", "30" });
HSSFDataValidation dataValidation = new HSSFDataValidation(addressList,
dvConstraint);
dataValidation.setSuppressDropDownArrow(false);
sheet.addValidationData(dataValidation);
Upvotes: 2