开发者

Create Dropdowns in Excel using java

开发者 https://www.devze.com 2023-02-10 06:43 出处:网络
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

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 inse开发者_StackOverflow社区rt values into dropdowns.I am using poi for creating the Excel.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号