rt

解决方案 »

  1.   

    strSQL = "select * from 表"
    Set myRS = myDBConn.Execute(strSQL)....
      

  2.   

    没有用到其他空件,datagrid,mshflexfrid等,直接保存出来
      

  3.   

        'rs.Open  "select ..."
        rs.Save "c:\" & Format(Now, "yyyymmddhhmmss") & ".dat", adPersistADTG
      

  4.   

    adPersistXML
    adPersistADTG 谢谢楼上,只能保存成这两种格式的文件,用excel就打不开了,还不行
      

  5.   

    Public Sub SQLToExcel(Rs_Data As ADODB.Recordset)
        Dim Irowcount As Integer
        Dim Icolcount As Integer
        Dim i As Integer
        
        Set xlapp = CreateObject("Excel.Application")
        Set xlBook = Nothing
        Set xlSheet = Nothing    Set xlBook = xlapp.Workbooks.Add
        Set xlSheet = xlBook.ActiveSheet
        
        '显示标题
        xlapp.Visible = True
        
        '添加查询语句,导入EXCEL数据
        Set xlQuery = xlSheet.QueryTables.Add(Rs_Data, xlSheet.Range("a1"))    xlQuery.Refresh
        xlQuery.FieldNames = True '显示字段名
        
        
        xlapp.Application.Visible = True
        Set xlapp = Nothing '"交还控制给Excel
        Set xlBook = Nothing
        Set xlSheet = Nothing
        xlapp.QuitEnd Sub导出到Excel的函数
      

  6.   

    不知道。。
    运行SQLToExcel(myrs)?
      

  7.   


    我接着楼上的写LZ不会用这个函数?    dim rs as new adodb.recordset 
        dim rn as new adodb.connection
        
        ......    SQLToExcel rs