📄 gzl_tj.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form19
BackColor = &H00FFC0C0&
Caption = "工作量计算"
ClientHeight = 5940
ClientLeft = 60
ClientTop = 345
ClientWidth = 9315
LinkTopic = "Form19"
MDIChild = -1 'True
ScaleHeight = 5940
ScaleWidth = 9315
WindowState = 2 'Maximized
Begin VB.Frame Frame_gzl
BackColor = &H00FFC0C0&
Caption = "教学工作量"
Height = 5655
Index = 2
Left = 120
TabIndex = 20
Top = 1200
Visible = 0 'False
Width = 11295
Begin VB.TextBox Text4
Height = 270
Left = 1320
MaxLength = 5
TabIndex = 35
Top = 1320
Width = 1215
End
Begin VB.CommandButton Command_dc3
Caption = "计算结果导出"
Enabled = 0 'False
Height = 495
Left = 6360
TabIndex = 33
Top = 4080
Width = 1575
End
Begin VB.TextBox Text3
Height = 270
Left = 2160
MaxLength = 5
TabIndex = 24
Top = 360
Width = 1215
End
Begin VB.ComboBox Combo3
Height = 300
Left = 1680
TabIndex = 23
Top = 840
Width = 1695
End
Begin VB.CommandButton Command6
Caption = "确 定"
Height = 375
Left = 240
TabIndex = 22
Top = 1800
Width = 1095
End
Begin VB.CommandButton Command5
Caption = "重 置"
Height = 375
Left = 2280
TabIndex = 21
Top = 1800
Width = 1095
End
Begin MSFlexGridLib.MSFlexGrid zjFlexGrid
Height = 3015
Left = 3720
TabIndex = 31
Top = 600
Width = 6855
_ExtentX = 12091
_ExtentY = 5318
_Version = 393216
Cols = 4
FixedCols = 0
BackColorBkg = 16761024
AllowUserResizing= 3
End
Begin VB.Label Label10
BackStyle = 0 'Transparent
Caption = "附加工作量:"
Height = 255
Left = 240
TabIndex = 34
Top = 1320
Width = 1095
End
Begin VB.Label Label9
BackStyle = 0 'Transparent
Caption = "请输入学期(20001):"
Height = 255
Left = 240
TabIndex = 27
Top = 360
Width = 1935
End
Begin VB.Label Label8
BackStyle = 0 'Transparent
Caption = "请选择教师姓名:"
Height = 255
Left = 240
TabIndex = 26
Top = 840
Width = 1575
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "所有工作信息显示:"
Height = 255
Left = 3720
TabIndex = 25
Top = 360
Width = 1935
End
End
Begin VB.Frame Frame_gzl
BackColor = &H00FFC0C0&
Caption = "科研工作量"
Height = 5655
Index = 1
Left = 120
TabIndex = 12
Top = 1200
Visible = 0 'False
Width = 11295
Begin VB.CommandButton Command_dc2
Caption = "计算结果导出"
Enabled = 0 'False
Height = 495
Left = 6480
TabIndex = 32
Top = 4320
Width = 1575
End
Begin VB.TextBox Text2
Height = 270
Left = 2160
MaxLength = 5
TabIndex = 16
Top = 360
Width = 1215
End
Begin VB.ComboBox Combo2
Height = 300
Left = 1680
TabIndex = 15
Top = 840
Width = 1695
End
Begin VB.CommandButton Command4
Caption = "确 定"
Height = 375
Left = 240
TabIndex = 14
Top = 1560
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "重 置"
Enabled = 0 'False
Height = 375
Left = 2280
TabIndex = 13
Top = 1560
Width = 1095
End
Begin MSFlexGridLib.MSFlexGrid kyFlexGrid
Height = 3015
Left = 3720
TabIndex = 30
Top = 600
Width = 6855
_ExtentX = 12091
_ExtentY = 5318
_Version = 393216
Cols = 4
FixedCols = 0
BackColorBkg = 16761024
AllowUserResizing= 3
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "请输入学期(20001):"
Height = 255
Left = 240
TabIndex = 19
Top = 360
Width = 1935
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "请选择教师姓名:"
Height = 255
Left = 240
TabIndex = 18
Top = 840
Width = 1575
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "科研信息显示:"
Height = 255
Left = 3720
TabIndex = 17
Top = 360
Width = 1335
End
End
Begin VB.Frame Frame_gzl
BackColor = &H00FFC0C0&
Caption = "教学工作量"
Height = 5655
Index = 0
Left = 120
TabIndex = 4
Top = 1200
Visible = 0 'False
Width = 11295
Begin VB.CommandButton Command_dc1
Caption = "计算结果导出"
Enabled = 0 'False
Height = 495
Left = 6480
TabIndex = 29
Top = 4320
Width = 1575
End
Begin MSFlexGridLib.MSFlexGrid jxFlexGrid
Height = 3015
Left = 3720
TabIndex = 28
Top = 600
Width = 6855
_ExtentX = 12091
_ExtentY = 5318
_Version = 393216
Cols = 4
FixedCols = 0
BackColorBkg = 16761024
AllowUserResizing= 3
End
Begin VB.CommandButton Command2
Caption = "重 置"
Enabled = 0 'False
Height = 375
Left = 2280
TabIndex = 10
Top = 1560
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "确 定"
Height = 375
Left = 240
TabIndex = 9
Top = 1560
Width = 1095
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1680
TabIndex = 8
Top = 840
Width = 1695
End
Begin VB.TextBox Text1
Height = 270
Left = 2160
MaxLength = 5
TabIndex = 6
Top = 360
Width = 1215
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "教学信息显示:"
Height = 255
Left = 3720
TabIndex = 11
Top = 360
Width = 1335
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "请选择教师姓名:"
Height = 255
Left = 240
TabIndex = 7
Top = 840
Width = 1575
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "请输入学期(20001):"
Height = 255
Left = 240
TabIndex = 5
Top = 360
Width = 1935
End
End
Begin VB.Frame Frame1
BackColor = &H00FFC0C0&
Caption = "请先选择计算对象"
Height = 855
Left = 120
TabIndex = 0
Top = 120
Width = 6855
Begin VB.OptionButton Option1
BackColor = &H00FFC0C0&
Caption = "总工作量计算"
Height = 255
Index = 2
Left = 5040
TabIndex = 3
Top = 360
Width = 1455
End
Begin VB.OptionButton Option1
BackColor = &H00FFC0C0&
Caption = "科研工作量计算"
Height = 255
Index = 1
Left = 2700
TabIndex = 2
Top = 360
Width = 1695
End
Begin VB.OptionButton Option1
BackColor = &H00FFC0C0&
Caption = "教学工作量计算"
Height = 255
Index = 0
Left = 360
TabIndex = 1
Top = 360
Width = 1695
End
End
End
Attribute VB_Name = "Form19"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "RVB_UniqueId" ,"41FF02250184"
Attribute VB_Ext_KEY = "RVB_ModelStereotype" ,"Form"
Dim mrc As ADODB.Recordset
Private mrc1 As ADODB.Recordset
Dim SQL As String
Private sql1 As String
Dim i As Integer
Private j As Integer '定义循环变量
Private Sub Command_dc1_Click() '结果导出(计算教学工作量)
On Error Resume Next
Dim colnum, rownum As Integer '存字段数量,记录书
Dim row As Integer '用来记录excel表的当前行
Dim Fieldlen() '存字段长度值
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
colnum = jxFlexGrid.Cols
rownum = jxFlexGrid.Rows
ReDim Fieldlen(colnum)
'往表内写入标题
xlSheet.Cells(1, 2).Value = "教学工作量计算结果表 "
xlSheet.Cells(3, 1).Value = "学期:" & Trim(Text1.Text)
'xlSheet.Cells(3, 2).Value = Trim(Text1.Text)
xlSheet.Cells(3, 3).Value = "教师姓名:"
xlSheet.Cells(3, 4).Value = Trim(Combo1.Text)
'往表内写入字段名
For i = 0 To colnum - 1
xlSheet.Cells(4, i + 1).Value = jxFlexGrid.TextMatrix(0, i)
Fieldlen(i) = LenB(jxFlexGrid.TextMatrix(0, i))
Next i
'开始往表内写查询结果
row = 5
For j = 1 To rownum - 1
For i = 0 To colnum - 1
If IsNull(jxFlexGrid.TextMatrix(row - 4, i)) = False Then
xlSheet.Cells(row, i + 1).Value = jxFlexGrid.TextMatrix(row - 4, i)
If LenB(jxFlexGrid.TextMatrix(row - 4, i)) > Fieldlen(i) Then '将字段的最大长度保存在Fieldlen()数组中
Fieldlen(i) = LenB(jxFlexGrid.TextMatrix(row - 4, i))
xlSheet.Columns(i + 1).ColumnWidth = Fieldlen(i)
End If
End If
Next i
mrc.MoveNext
row = row + 1
Next j
With xlSheet
.Cells(1, 2).Font.Name = "黑体" '设标题为黑体字
.Cells(1, 2).Font.Size = 24 '标题字体大小为24
.Range(.Cells(4, 1), .Cells(row - 1, colnum)).Borders.LineStyle = xlContinuous
'设表格边框样式
End With
xlApp.Visible = True '显示表格
xlBook.Save '保存'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -