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

    Default read values of userform Textbox and Checkbox

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

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    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.

    Regards,
    Jim
    Last edited by jim829; 03-19-2015 at 02: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, 07:31 PM
  2. Limit Textbox Values
    By rjagan in forum NetBeans
    Replies: 1
    Last Post: 03-22-2011, 10: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, 08: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, 11:06 AM
  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, 11:55 AM

Posting Permissions

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