C# 如何勾选Excel复选框
Excel.Application app = new Excel.ApplicationClass();
Excel.Workbook workbook = app.Application.Workbooks.Open("c:\\test.xls", Missing.Value, false,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
Excel.Sheets sheets = workbook.Worksheets;
Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
Excel.CheckBox cbx = worksheet.CheckBoxes(1) as Excel.CheckBox;cbx.Value = true;
workbook.Save();
未处理COMException
Exception from HRESULT: 0x800A03EC
检查异常的ErrorCode属性以确定COM对象返回的HRESULT。
执行到Excel.CheckBox cbx = worksheet.CheckBoxes(1) as Excel.CheckBox;就报错了.
实现C#可以勾选Excel复选框cbx.Value = true; (CheckBox.Value = True)
------解决方案--------------------
UP