Quantcast
Channel: Java Programming Forum - Learn Java Programming - Apache POI
Viewing all articles
Browse latest Browse all 120

read values of userform Textbox and Checkbox

$
0
0
Hi,

I have an excel sheet that is used as a form (created using Developer mode). It contains labels, textboxes and checkboxes.
Using POI I have managed to get a list of these objects as instance of HSSFObjectData (using Scala):
Code:

  val file = new FileInputStream( new File("c:\\tmp\\test.xls"))
  val workbook = new HSSFWorkbook(file)
 
  val sheet = workbook.getSheetAt(0)
    val pat = sheet.getDrawingPatriarch
   
    pat.getChildren.asScala.toList.foreach { shape=>

      if(shape.isInstanceOf[HSSFObjectData]) {
        val box = shape.asInstanceOf[HSSFObjectData]
        if(box.getOLE2ClassName == "Forms.TextBox.1") {
              println(box.getWrapText.toString) //==> 0
          }
        }
      }

But from HSSFObjectData, I cannot see how to access the text value of a textbox or the selected value of a checkbox.
This information seems to be accessible from HSSFTextbox and HSSFCheckbox object, but I have not managed to find a way to access these instances.

Can anybody give me a hint ?

Best Regards,
Olivier

Viewing all articles
Browse latest Browse all 120

Trending Articles