快表VBA通过钉钉API获取花名册
- Imports System.Windows
- Imports System.Windows.Controls
- Imports C1.Silverlight
- Imports C1.Silverlight.C1MessageBoxButton
- Imports C1.Silverlight.C1MessageBoxIcon
- Imports Newtonsoft.Json
- Imports Newtonsoft.Json.Linq
- Imports System.IO
- Imports System.Text
- Namespace ExcelViewVBDotnet
- Public Class StandardInterface '自定义名称
- Implements Interfaces.IExcelWorkBook
- Public Property ActiveWorkbook() As IWorkbook Implements Interfaces.IExcelWorkBook.Workbook
- Dim EV As SpreadsheetGear.Windows.Controls.WorkbookView
- Dim Range As SpreadsheetGear.IRange
- Dim CF, VW As Object
- Dim TS As StackPanel
- Dim kb_access_token As String
- Dim kb_next_cursor As Integer
-
- Public Sub Workbook_Open(OldRoot As Grid, NewRoot As Grid, Excel As SpreadsheetGear.Windows.Controls.WorkbookView) Implements Interfaces.IExcelWorkBook.Workbook_Open
- EV = Excel
- Excel.GetLock()
- Range = ActiveWorkbook.ActiveWorksheet.Range
- Excel.ReleaseLock()
- CF = OldRoot.Children(1) '绑定工具条触发,不能测试运行
- TS = CType(OldRoot.Children(5), StackPanel)
- '工具条添加第一个按钮
- Dim BT1 As New Button
- BT1.Name = "BT_AN1" '按钮名,不能与其他按钮名称重复,下同。
- 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()
- ActiveWorkbook.WorkbookSet.GetLock()
- kb_next_cursor = ActiveWorkbook.Worksheets("SheetSet").Range("A3").Value
- 'MessageBox.Show(kb_next_cursor)
- If kb_next_cursor = 0 And ActiveWorkbook.ActiveWorksheet.Range("B2").Text <> "" Then
- If MessageBox.Show("是否清空内容并重新获取", "提示", MessageBoxButton.OKCancel) = MessageBoxResult.OK Then
- ActiveWorkbook.ActiveWorksheet.ProtectContents = False
- ActiveWorkbook.ActiveWorksheet.UsedRange.Offset(3, 0).EntireRow.Delete()
- ActiveWorkbook.ActiveWorksheet.UsedRange.Offset(1, 0).ClearContents()
- End If
- Else
- Dim wc As New WebClient
- wc.Encoding = Encoding.UTF8
- wc.Headers.Item("Content-Type") = "application/json"
- Dim address As String = "https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/queryonjob?access_token=" + kb_access_token
复制代码
所有内容请回复后下载
|
|
苏武牧表