Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Sat Feb 22, 2014 12:54 pm

I am loading an existing XLS spreadsheet and inserting data into it. Im am OK whith adding data to cell or ranges but my spreadsheet also contains Textbox and Checkbox controls that I need to maniplulate.

Can anyone help with how I add text to a Textbox on the opened spreadsheet?

And how to tick/untick a checkbox?

I need to find them by name ie. "Check Box 1" or "TextBox 1"

mark.dillon
 
Posts: 4
Joined: Sat Feb 22, 2014 11:55 am

Sat Feb 22, 2014 4:43 pm

OK, I figured out how to set text of the textboxes in my spreadsheet but cant get the checkboxes to work. See code example below. I have even tried iterating through the checkboxes to output their names to a string but the string is returned empty. Can anyone help?

Code: Select all
'TEXTBOX CODE - THIS WORKS FINE

Dim ee As TextBoxCollection = sheet.TypedTextBoxes

        For Each Titem In ee
            If Titem.Name = "TextBox 1" Then
                Titem.Text = "Hello World"
            End If
        Next

'CHECKBOX CODE - THIS WONT WORK

Dim ff As CheckBoxCollection = sheet.TypedCheckBoxes
     
        For Each Citem As ICheckBox In ff
            If Citem.Name = "Check Box 5" Then
                Citem.CheckState = CheckState.Checked
            End If
        Next

mark.dillon
 
Posts: 4
Joined: Sat Feb 22, 2014 11:55 am

Mon Feb 24, 2014 8:49 am

Hello,

Sorry for the inconvenience caused by us. I have reproduced the issue with CheckBox.
And I have submitted the issue to our dev team. Once there is any progress,
we will tell you immediately.
If you have any questions, welcome to get it back to us.

Regards,
Benjamin
E-iceblue support team
User avatar

Benjamin Du
 
Posts: 82
Joined: Thu Jul 25, 2013 2:38 am

Mon Feb 24, 2014 10:43 am

Hi Benjamin

thanks for the response.

You may be interested to know that if I rename a checkbox to "Checkbox1" in my template xls sheet the code below works fine. It doesn't work with the default name of the checkbox in excel. Would be good if you can get that fixed as it would be inconvenient to have to rename all our checkboxes :).

Code: Select all
Dim ff As CheckBoxCollection = sheet.TypedCheckBoxes
     
        For Each Citem As ICheckBox In ff
            If Citem.Name = "Checkbox1" Then
                Citem.CheckState = CheckState.Checked
            End If
        Next

mark.dillon
 
Posts: 4
Joined: Sat Feb 22, 2014 11:55 am

Tue Feb 25, 2014 8:58 am

Hello,

Thank you for your information.
Would you please provide us your project and all related files to manipulate CheckBox? (you rename
a checkbox to "Checkbox1" and the code below works fine)
It will help us to solve your issue more quickly.
Thank you in advance.
If you get any questions, welcome to get it back to us.

Thanks and Regards,
Benjamin
E-iceblue support team
User avatar

Benjamin Du
 
Posts: 82
Joined: Thu Jul 25, 2013 2:38 am

Wed Jun 18, 2014 7:48 am

Hello,

Your issue has been resolved. Welcome to download and test the new version: Spire.XLS Pack Hotfix Version:7.4.16
http://www.e-iceblue.com/Download/download-excel-for-net-now.html.
If you get any questions, welcome to get it back to us.

Regards,
Benjamin
E-iceblue support team
User avatar

Benjamin Du
 
Posts: 82
Joined: Thu Jul 25, 2013 2:38 am

Return to Spire.XLS