Free Support Forum - aspose.com

Setting Name Property of Checkbox

Hi !!

I have created runtime checkbox by Aspose.cell. How can I change the Name property

of checkbox.

Thanks a lot !

Hi,

Please use CheckBox.Name property to get / set the name string for the checkbox.

Here is the the sample code:

//Instantiate a new Workbook.
Workbook excelbook = new Workbook();
//Add a checkbox to the first worksheet in the workbook.
int index = excelbook.Worksheets[0].CheckBoxes.Add(5, 5, excelbook.Worksheets[0].Cells.GetRowHeightPixel(5), excelbook.Worksheets[0].Cells.GetColumnWidthPixel(5));
//Get the checkbox object.
Aspose.Cells.CheckBox checkbox = excelbook.Worksheets[0].CheckBoxes[index];
//Set its text string.
checkbox.Text = "Click it!";
//Put a value into B1 cell.
excelbook.Worksheets[0].Cells["B1"].PutValue("LnkCell");
//Set B1 cell as a linked cell for the checkbox.
checkbox.LinkedCell = "B1";
//Check the checkbox by default.
checkbox.Value = true;
checkbox.Name = "MyCheckBox";
//Save the excel file.
excelbook.Save("d:\\test\\11new_stcheckboxes.xls");

Thank you.

I tried, however when I try to put Name property, I don't get it in inteliget.

and I get an error mentioning 'Aspose.Cells.CheckBox does not contain defination for Name'

Appreciate if you guide me.

Hi,

I think you are using some older version of Aspose.Cells, Please try the latest version (4.4.1: http://www.aspose.com/community/files/51/aspose.cells/entry111612.aspx) as the property is there in the APIs.

Thank you.