Results 1 to 2 of 2
  1. #1
    opoppon is offline Member
    Join Date
    Mar 2015
    Rep Power

    Default read values of userform Textbox and Checkbox


    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):
    Java 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,

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: read values of userform Textbox and Checkbox

    I am not familiar with the classes you are using but the following construct is incorrect:

    Java Code:
    if(box.getOLE2ClassName == "Forms.TextBox.1") {   
       println(box.getWrapText.toString) //==> 0
    You should use equals() and not == to compare strings or other objects which depend on internal state. Also, getOLE2ClassName and getWrapText look like getter methods but you are not calling them as such.

    Last edited by jim829; 03-19-2015 at 03:46 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. checkbox values in mysql
    By aalhazm in forum JDBC
    Replies: 0
    Last Post: 05-25-2013, 08:31 PM
  2. Limit Textbox Values
    By rjagan in forum NetBeans
    Replies: 1
    Last Post: 03-22-2011, 11:16 AM
  3. How to get values for unselected checkbox values
    By sarath13 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 01-07-2011, 09:54 AM
  4. draw in jpanel using values input in textbox
    By New to JAVA in forum AWT / Swing
    Replies: 6
    Last Post: 07-08-2009, 12:06 PM
  5. passing object as value for checkbox values??
    By Pooja Deshpande in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-17-2009, 12:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts