我试图从Excel工作表中获取复选框的值。我发现了一些看起来很接近的东西,但它不尽如人意:
xl.OLEObjects oleObjects = AddressWorksheet.OLEObjects() as xl.OLEObjects;
foreach (xl.OLEObject item in oleObjects)
{
//VBE.CheckBox xlCB = item.Object as VBE.CheckBox;
var xlCB = item.Object as VBE.CheckBox;
Console.WriteLine("checkbox: " + item.Name);
Console.WriteLine("Value: " + xlCB.get_Value());
Marshal.ReleaseComObject(xlCB); xlCB = null;
}
这给了我一个错误"无法获取OLEObject类的Object属性"
有什么实际可行吗?看起来它应该是你应该做的事情。