Dim i As Integer, j As Integer 'i为列,j为行
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlApp.Visible = True: xlApp.DisplayAlerts = False
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlApp.Worksheets(1)
rst.MoveFirst
'----------------------设置列标题------------------------------------------
For i = 1 To rst.fields.Count
xlSheet.Cells(1, i) = rst.fields(i - 1).Name
Next
'-----------------------------------------------------------------------
'-----------------------把rst中内容显示到表中-----------------------
j = 2 'j为列,i为行
Do While Not rst.EOF
For i = 1 To rst.fields.Count
xlSheet.Cells(j, i) = rst.fields(i - 1).Value
Next
j = j + 1
rst.MoveNext
Loop
'-------------------------------------------------------------------------------