用open打开文件,
一条一条write或print进去。

解决方案 »

  1.   

    to foolishtiger(吴文智) 
        哈哈,你的记性不错呀。
    to baoxiang(包香) 
       能否具体点,谢谢了。
      

  2.   

    baoxiang(包香) 没明白你的意思,他误解了.
      
      

  3.   

    Sub Find2Excel(ByVal PageID As Long, ByVal PageName As String)
      '把查询到的数据资料导出到EXCEL中去
      
      On Error GoTo ExcelErr
      
      Dim xlApp As Excel.Application
      Dim xlBook As Excel.Workbook
      Dim xlSheet As Excel.Worksheet
      Set xlApp = CreateObject("Excel.Application")
      xlApp.WindowState = xlMaximized
      xlApp.Visible = True
      Set xlBook = xlApp.Workbooks.Add
      Set xlSheet = xlBook.Worksheets(1)
      
      Set rs = New adodb.Recordset
      
      rs.Open "select * from T", conData, adOpenDynamic
      lngN = rs.Fields.Count
      For I = 0 To lngN - 1
        strTemp = rs.Fields(I).Name
          rs1.Open "select FldFieldName from TblField where FldPageID=" & PageID & " and FldFieldID=" & Val(Mid(strTemp, 2)), conData, adOpenDynamic
          If Not rs1.EOF Then
            strTemp = rs1.Fields("FldFieldName")
          End If
          rs1.Close
        xlSheet.Cells(1, I + 1) = strTemp
        
      Next I
      lngRows = 2
      Do While Not rs.EOF
        For I = 0 To lngN - 1
          xlSheet.Cells(lngRows, I + 1) = rs.Fields(I).Value
        Next I
        lngRows = lngRows + 1
        rs.MoveNext
      Loop
      rs.Close
      
      Set rs1 = Nothing
      Set rs = Nothing
      
      
      xlSheet.Name = PageName
      
      xlApp.Visible = True
      Set xlApp = Nothing
      
      Exit Sub
    ExcelErr:
      MsgBox "输出到电子表格出现错误:" & Err.Description, 48, App.Title
      
      
    End Sub