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.

Wed May 29, 2013 5:30 pm

Hi!

Before use Spire I was using the Microsoft Interop library. In this line was how I referenced (and edit the value) an existing Checkbox in my XLS

Code: Select all
Microsoft.Office.Interop.Excel.CheckBox cb = (Microsoft.Office.Interop.Excel.CheckBox)objWorksheet.Shapes.Item("chkHorario").OLEFormat.Object;
cb.Value = 1;


How can I do this in Spire?

Regards.

veljean
 
Posts: 11
Joined: Tue May 28, 2013 6:22 pm

Thu May 30, 2013 2:57 am

Dear veljean,

Thanks for your inquiry.
Please try checkbox.Text = "checkbox000"; to edit text of an existing checkbox and try checkbox.CheckState = CheckState.Unchecked; to check or uncheck an existing checkbox.


I attached some sample code below.

Code: Select all
  Worksheet worksheet = workbook.Worksheets[0];
         
           var c = worksheet.CheckBoxes[0];

            c.Text = "checkbox000";
            c.CheckState = CheckState.Checked;


There is any issue, please feel free to contact us.

Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu May 30, 2013 2:24 pm

Hi.
The line

Code: Select all
var c = sheet.CheckBoxes[0];


throw me an error (array out of index), seems that sheet.CheckBoxes[0] is null.
I sent you te template that I am loading...

Code: Select all
 string pathFile = Server.MapPath("~\\Plantillas\\" + "InspeccionOcular.xls");
           
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(pathFile);
            Worksheet sheet = workbook.Worksheets[0];


Something strange is when I save the file with Spire method "Save" and I open the resulting file , all check boxes are gone... :shock:
Attachments
InspeccionOcular.rar
(54.84 KiB) Downloaded 390 times

veljean
 
Posts: 11
Joined: Tue May 28, 2013 6:22 pm

Fri May 31, 2013 2:23 am

Dear veljean,

Thanks for your feedback.
I did a test with your excel file, and reproduced the error(array out of index), but didn't reproduce the issue about all check boxes are gone when using Save() method. Could you please provide us the code about using Save() method? Thanks!
My dev colleague is working on the error(array out of index). There is any update on it, we will tell you.

Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri May 31, 2013 1:54 pm

Yes, Of course!

The line of code is

Code: Select all
workbook.SaveToFile(pathFile + @"\Rep_Inspeccion.xlsx", ExcelVersion.Version2007);

veljean
 
Posts: 11
Joined: Tue May 28, 2013 6:22 pm

Mon Jun 03, 2013 3:04 am

Dear veljean,

Thanks for your response.
I have reproduced the issue with your code, and posted it to our dev team. Sorry for the inconvenience.
There is any update on your issues, we will tell you.

Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Aug 29, 2013 7:43 am

Hello,

The issue has been resolved, and the new hot_fix of Spire.Xls has been released. Please download and test Spire.XLS Pack Hotfix Version:7.1.6.
http://www.e-iceblue.com/Download/download-excel-for-net-now.html

If there are any questions, welcome to get it back to us.

Thanks And Regards,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Aug 30, 2013 5:27 pm

Thank you!

veljean
 
Posts: 11
Joined: Tue May 28, 2013 6:22 pm

Sat Feb 22, 2014 8:09 pm

Hi veljean, were you able to set checkbox values by referencing the checkbox name?

I have just come from microsoft interop too and cant seem the get the checkbox by name.

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

Tue Feb 25, 2014 7:37 am

Hello,

We are working on the issue at present. Once the issue is fixed, we will tell you immediately.
If you have any questions, please tell us.

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

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

Sun Oct 30, 2016 9:43 pm

Hi,

To me it seems this issue is unresolved, I am facing issue with checkboxes too when they are of ActiveX type.


interop / vba code example here.
http://wellsr.com/vba/2015/excel/comple ... heckboxes/


Can you give example of how to set value of checkbox on an ActiveX, or is this not supported ?

pedgaard
 
Posts: 24
Joined: Fri May 20, 2016 3:12 pm

Mon Oct 31, 2016 3:05 am

Hi pedgaard,

Thanks for your inquiry.
Sorry that at present Spire.XLS doesn't support ActiveX type of checkbox, but we have added this new feature into our schedule.
Once there is any great progress, we will inform you immediataly. Sorry for inconvenience.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Oct 31, 2016 11:30 am

Thanks for response.

If anyone else faces this issue, a workaround if you must use ActiveX and not form controls is to link the ActiveX Checkbox to a cell, and then use Spire to fill out TRUE/FALSE to this cell.

pedgaard
 
Posts: 24
Joined: Fri May 20, 2016 3:12 pm

Return to Spire.XLS