Dim i As Integer
Dim j As Integer
'Dim xlApp As Excel.Application
'Dim xlBook As Excel.Workbook
'Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.add
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Cells(2, 11) = "总人数"
xlSheet.Cells(2, 12) = Text4.Text + "人"
For i = 0 To Val(Text4.Text) - 1
DataGrid2.Row = i
For j = 0 To 11
DataGrid2.Col = j
xlSheet.Cells(i + 3, j + 1) = DataGrid2.Text
Next j
Next i
用此法将表中的内容转到excel中打印