Microsoft.Office.Interop.Excel添加单选button到工作表

我一直在寻找如何以编程方式将单选button添加到Excel工作表的示例,但无法得到直接的答案。 我试过使用Microsoft.Office.Interop.Excel和Microsoft.Office.Tools.Excel但都没有工作。 我正在使用的系统已经有Microsoft.Office.Interop.Excel作为参考,所以除非有人反对使用这个程序集,这将是我的首选。

//propertyWorkSheet is a Microsoft.Office.Interop.Excel worksheet Microsoft.Office.Tools.Excel.Application xlApp = new Excel.Application(); Microsoft.Office.Tools.Excel.Worksheet worksheet = (Microsoft.Office.Tools.Excel.Worksheet)propertyWorksheet; Microsoft.Office.Tools.Excel.Range selection = worksheet.get_Range("A12:A12", "A12:A12"); Microsoft.Office.Tools.Excel.Controls.Button button = new Microsoft.Office.Tools.Excel.Controls.Button(); worksheet.Controls.AddControl(button, selection, "Button"); 

做了一些更多的挖掘,并与我的代码和它的工作。

  Microsoft.Office.Interop.Excel.Buttons buttons = propertyWorksheet.Buttons(System.Reflection.Missing.Value) as Microsoft.Office.Interop.Excel.Buttons; Microsoft.Office.Interop.Excel.Button button = buttons.Add(33, 33, 33, 33); button.Caption = "Test BUTTON";