1

Is it possible with Apache POI to create a checkbox in a specific cell?

I already found a solution with drop down list, but I'm curious to know if it is possible to insert real checkbox?

XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("test sheet");

XSSFDataValidationHelper helper = new XSSFDataValidationHelper(sheet);
XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint) helper.createExplicitListConstraint(new String[] {"Checked", "Unchecked"});
CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);
XSSFDataValidation validation = (XSSFDataValidation)helper.createValidation(dvConstraint, addressList);
validation.setShowErrorBox(true);
sheet.addValidationData(validation);

Thank you.

4
  • 1
    stackoverflow.com/questions/58733418/… Commented Feb 29, 2020 at 14:59
  • Yep I saw this post, but it is very complex compare to the dropdown list... Commented Feb 29, 2020 at 15:00
  • 1
    What you are calling a "dropdown list" is not a control. Instead it is the GUI representation of a data validation list. This is something totally different. There is not any data validation which GUI representation would be a checkbox. Commented Feb 29, 2020 at 15:04
  • @AxelRichter Thank you for your detailed answer. Commented Feb 29, 2020 at 15:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.