我通过 vb.net 为 excel 创建了一个示例插件:
Imports System.Runtime.InteropServices
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim excelApp As Excel.Application
excelApp = CType(Marshal.GetActiveObject("Excel.Application"), Excel.Application)
' Dim xlwb As Excel.Workbook = Globals.ThisAddIn.Application.Worksheets.Add()
' dim sheet As Excel.Worksheet = xlwb.ActiveSheet
Dim sheet As Excel.Worksheet
sheet = excelApp.ActiveSheet
sheet.Range("A1").Value = "OK"
Me.Close()
End Sub
End Class
我为 excel 的单元格设置了值: sheet.Range("A1").Value = "OK"
但它没有设置。为什么?怎么修?