I have a Excel Tamplate in which i have Checkbox placed in it. I want to do Check uncheck/Checkbox depending on some condition in Spreadsheet Gear. Checkbox is already available in the Excel Sheet. I am using Spreadsheetgear 2008. I googled but cant find answer. Can Comeone please give me any refernce for this.
Asked
Active
Viewed 995 times
1 Answers
2
You can set the state of a CheckBox one of two ways:
- Set the CheckBox's IControlFormat.Value property to the desired value.
- If the CheckBox is linked to a cell (see IControlFormat.LinkedCell), set the linked cell's value and it should update accordingly.
Example:
using SpreadsheetGear;
using SpreadsheetGear.Shapes;
// Open workbook containing the CheckBox
IWorkbook workbook = Factory.GetWorkbook("CheckBox.xls");
// Assume CheckBox is in Sheet1
IWorksheet worksheet = workbook.Worksheets["Sheet1"];
// CheckBoxes reside within a Shape, so access the shape
Shapes.IShape shape = worksheet.Shapes["Check Box 1"];
// Access the CheckBox directly
Shapes.IControlFormat checkbox = shape.ControlFormat;
// A checkbox’s IControlFormat.Value will be set to 0 if it is unchecked,
// 1 if it is checked, and 2 if it is in an "indeterminate" state.
checkbox.Value = 1;
// Assume CheckBox is linked to cell A1 in this worksheet
worksheet.Cells["A1"].Value = true;

Tim Andersen
- 3,014
- 1
- 15
- 11