I'm trying to get/set checkbox value in Word document (.doc) with Apache POI.
I looked HWPFDocument API at poi.apache.org, but haven't found anything suitable... Maybe somebody have a solution?
Thank You!
I'm trying to get/set checkbox value in Word document (.doc) with Apache POI.
I looked HWPFDocument API at poi.apache.org, but haven't found anything suitable... Maybe somebody have a solution?
Thank You!
Unfortunately, this is currently not supported by POI. What does work is to read out (not set) dropdown lists via CharacterRun.getDropDownListValues()
and CharacterRun.getDropDownListDefaultItemIndex()
.
Technically those dropdown lists are closely related to checkboxes, though. So it should not be too difficult to add the respective functionality to POI, if desired. Your entry point is a NilPICFAndBinData structure (handled by this class in POI), which leads you to some FFData (maps to this class in POI). Inside that you will find FFDataBits. These eventually contain an iRes
value which encodes the status of that checkbox.
- This is exactly the same behavior as for dropdown lists, only that the iType
of FFDataBits will be iTypeChck instead of iTypeDrop and has to be interpreted in a slightly different way.
I had the same problem. Had to write a VBA macro that gets the value of the checkboxs, stores it in a portable database and I get it from there.