?? frmfindstuent_fee.vb
字號(hào):
?Public Class FrmFindStuent_Fee
Private Sub FrmFindStuent_Fee_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ComboDBOperator.SelectedIndex = 0
End Sub
Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOK.Click
DGVResult.DataSource = DBStudent.LoadStudent("Fee", Me.TxtFee.Text, Me.ComboDBOperator.Text)
End Sub
Private Sub BtWord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtWord.Click
Dim wordApp As New Word.Application
Dim myDoc As Word.Document
Dim oTable As Word.Table
Dim rowIndex, colIndex As Integer
rowIndex = 1
colIndex = 0
wordApp.Documents.Add()
myDoc = wordApp.ActiveDocument
Dim Table As New DataTable
Table = DBStudent.LoadStudent("Fee", Me.TxtFee.Text, Me.ComboDBOperator.Text)
oTable = myDoc.Tables.Add(Range:=myDoc.Range(Start:=0, End:=0), NumRows:=Table.Rows.Count + 1, NumColumns:=Table.Columns.Count)
'將所得到的表的列名,賦值給單元格
Dim Col As DataColumn
Dim Row As DataRow
For Each Col In Table.Columns
colIndex = colIndex + 1
oTable.Cell(1, colIndex).Range.InsertAfter(Col.ColumnName)
Next
'得到的表所有行,賦值給單元格
For Each Row In Table.Rows
rowIndex = rowIndex + 1
colIndex = 0
For Each Col In Table.Columns
colIndex = colIndex + 1
oTable.Cell(rowIndex, colIndex).Range.InsertAfter(Row(Col.ColumnName))
Next
Next
oTable.Borders.InsideLineStyle = 1
oTable.Borders.OutsideLineStyle = 1
wordApp.Visible = True
End Sub
End Class
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -