先引用MicroSoft Excel
Dim xlApp As New Excel.Application, xlBook As New Excel.Workbook, xlSheet As New Excel.Worksheet
Dim Conn As New ADODB.Connection, Rs As New ADODB.Recordset
Rs.Open StrSQL,Conn,1,1 '查询记录
If not Rs.EOF Then
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
For Fld_j = 0 To Rs.Fields.Count - 1
xlSheet.Cells(1, Fld_j + 1) = RsMain.Fields(Fld_j).Name
Next Fld_j
xlSheet.Range("A2").CopyFromRecordset Rs
EndIf
Rs.Close