Fetching Option or Radio Button worksheet form control from an excel file using POI
December 8, 2010
I was recently working on a task where I wanted to read an excel file that had some radio button (also know as Option button in excel terminology). I was using Apache’s POI framework. The objective of the task was to read/write the state of a radio button (state meaning if radio button is selected or deselected). Since I was new to POI, I went through the documentation but couldn’t find any useful stuff on how to deal with Worksheet form controls (Option buttons are type of form control). Googling on this issue wasn’t so helpful. All I could gather was that, POI does provide a Class that represents Option button, but does not provide any API to interact with it. I am using POI version 3.6, and the class that represents this Option button is called as CommonObjectDataSubRecord . This class is sub-class of SubRecord .
Unfortunately I couldn’t find any sample code that parses and excel file and fetches the Option button, so I have to hand-craft it (was bit painful, but looking at error stack traces on various POI forums and reading actual POI source code helped me). So it here goes…might be helpful for others
Hope this helps you