本帖最后由 hessen 于 2019-8-22 08:19 编辑
菜单栏自定义按钮执行提取公式
功能说明:
在填报、修改、查阅模板时,顶部的菜单栏添加一个自定义按钮并在点击按钮时执行表间提取公式。
支持版本:
企业版7.0以上
效果:
- Imports SpreadsheetGear
- Imports C1.Silverlight
- Imports C1.Silverlight.C1MessageBoxButton
- Imports C1.Silverlight.C1MessageBoxIcon
- Imports Newtonsoft.Json
- Imports Newtonsoft.Json.Linq
- Imports System.Windows.forms
- Namespace ExcelViewVBDotnet
- Public Class StandardInterface
- '预留位置1
- '预留位置2
- Dim EV As SpreadsheetGear.Windows.Co**ols.WorkbookView,AW As SpreadsheetGear.IWorkbook,Range As SpreadsheetGear.IRange
- Dim CF As Textbox,VW As Object
- Dim TS As StackPanel
- Public Sub Workbook_Open(OldRoot As Object,NewRoot As Object,Excel As SpreadsheetGear.Windows.Co**ols.WorkbookView)
- EV = Excel
- Excel.GetLock()
- AW = Excel.ActiveWorkbook
- Range = AW.ActiveWorksheet.Range
- Excel.ReleaseLock()
- CF = CType(OldRoot.Children(1),TextBox)
- TS = CType(OldRoot.Children(5),StackPanel)
-
- '工具条添加第一个按钮
-
- Dim BT1 As New Button
- BT1.Name = "BT_TQ"
- BT1.Content = "执行提取公式"
- BT1.Margin= New Thickness(0, 2, 0, 2)
- BT1.Padding= New Thickness(13, 3, 13, 3)
- BT1.Style=CType(Application.Current.Resources("ButtonStyle3"),style)
- BT1.Foreground = CType(Application.Current.Resources("Foreground1"),System.Windows.Media.Brush)
- AddHandler BT1.Click, Sub()
- CF.Tag = "1,提取物资" '公式类型:1为提取,2为传递。逗号后加执行的公式名称,与表间公式中的显示的名称一致
- CF.Text = "#执行公式" '执行提取公式写入"#执行公式",执行SQL语句写入"#执行SQL"
- End Sub
- TS.Children.Insert(16, BT1)
-
- End Sub'打开时执行事件
- Public Sub RangeSelection(sender As Object,e As SpreadsheetGear.Windows.Co**ols.RangeSelectionChangedEventArgs)
- End Sub'单元格选择后执行的事件
- Public Sub RangeChanged(sender As Object,e As SpreadsheetGear.Windows.Co**ols.RangeChangedEventArgs)
- End Sub'单元格编辑完成后执行事件
- Public Sub ButtunClick(sender As Object,e As SpreadsheetGear.Windows.Co**ols.ShapeActionEventArgs)
- End Sub'按钮/标签点击事件
- Public Sub FollowHyperlink(sender As Object)
- End Sub '暂不支持
- End Class
- ' 注:除事件字眼下可以自定义代码外的所有代码不允许改动,否则编译将有可能失败。
- End Namespace
复制代码
|
hessen