注册 登录
编程论坛 VB.NET论坛

求助,如何在VB.net中使用EXCEL插件

Icand 发布于 2011-04-07 14:54, 793 次点击
想在的窗体中插入Excel的表格,并在同一个窗体中设置些按钮进行操作。
就像附件中的样子,请高手解答如果实现,谢谢啦~
只有本站会员才能查看附件,请 登录
3 回复
#2
bate62011-04-08 20:09
做excel插件开发,可能需要为excel添加自定义的工具栏。这个也是非常的简单的。

以下是引用片段:
  Public Class ConnectClass Connect
  Implements Extensibility.IDTExtensibility2
  Dim app As Excel.Application
  Dim wb As Excel.Workbook
  Dim ws As Excel.Worksheet
  Dim addInInstance As Object
  Dim pasteText As Microsoft.Office. ‘定义一个工具栏按钮
  Public Sub OnBeginShutdown()Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
  End Sub
  Public Sub OnAddInsUpdate()Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate
  End Sub
  Public Sub OnStartupComplete()Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete
  End Sub
  Public Sub OnDisconnection()Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array)
  Implements Extensibility.IDTExtensibility2.OnDisconnection
  End Sub
  Public Sub OnConnection()Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode,
  ByVal addInInst As Object, ByRef custom As System.Array)
  Implements Extensibility.IDTExtensibility2.OnConnection
  If TypeOf (application) Is Excel.Application Then app = CType(application, Excel.Application)
  addInInstance = addInInst
  wb = app.ActiveWorkbook
  ws = CType(wb.ActiveSheet, Excel.Worksheet)
  Dim toolbar As Microsoft.Office. = Nothing
  If Not app Is Nothing Then
  toolbar = AddToolbar(app, "专用工具栏") ’添加工具栏
  End If
  ’ 建立按钮添加文本
  pasteText = MakeANewButton(toolbar, "Insert text",
  1044, AddressOf pasteText_Click) ’添加工具栏按钮并帮定事件
  End Sub
  ’添加工具栏
  Private Function AddToolbar()Function AddToolbar(ByVal ex As Excel.Application, _
  ByVal toolbarName As String) As Microsoft.Office.
  Dim toolBar As Microsoft.Office. = Nothing
  Try
  ’ 为add-in建立一个命令条
  toolBar = CType((toolbarName,
  Microsoft.Office.Core.MsoBarPosition.msoBarTop, , True),
 
#3
Icand2011-04-09 01:35
回复 2楼 bate6
你好,谢谢你的回帖~
能说明下什么自定义工具栏吗,还有这个代码写在哪里的?~
#4
Icand2011-04-09 15:07
回复 2楼 bate6
这几天又用了webbrowser,可以会无法显示,唉
1