我有一个Excel Tamplate,其中放置了Checkbox。 我想根据Spreadsheet Gear中的某些条件检查取消选中/复选框。 复选框已在Excel工作表中提供。我正在使用Spreadsheetgear 2008。 我用谷歌搜索但无法找到答案。 Can Comeone请给我任何参考。
答案 0 :(得分:2)
您可以通过以下两种方式设置CheckBox的状态:
示例:
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;