EXCEL可以调用microsoft query,在那里可以写sql 语句取sql server的数据,可以不用编程,也可以用vb实现。

解决方案 »

  1.   

    用BCP吧:
    bcp "test.dbo.sysobjects" out "c:\aa.xls" -c -q -U"sa" -P""
    在VB里调用操作系统命令就行了。
      

  2.   

    在EXCEL可以通过ODBC,编写VBA的脚本直接访问SQLSERVER,你可以看看EXCEL的HELP,或到文档中心搜索一把,
      

  3.   


    找到一个帖子,希望对你有HELP:
    http://www.csdn.net/expert/topic/504/504360.xml?temp=.9366571
      

  4.   

    用VB可以,使用ADO来处理。方法是把EXCEL也当成一个数据库来处理。等于在两个数据库间传递数据!
      

  5.   

    用VB将数据放到一个记录集中,
    用VBA打开一个EXCEL文件,循环将记录放入EXCEL的单元格中。
    代码很简单的。
      

  6.   

    Public Sub SetExcel()
    Dim i As Long
    Dim count As Integer
          Dim oExcel  As Excel.Application
          Dim oBook As Excel.Workbook
          Dim oSheet As Excel.Worksheet
    dim sql$
    sql="select filed1,filed2 from test"
    dim DateBound as new adodb.recordset
    datebound.open sql,cn
             Set oExcel = CreateObject("Excel.Application") '= "Microsoft excel")
             Set oBook = oExcel.Workbooks.Add
             Set oSheet = oBook.Worksheets(1)
     oSheet.Cells(1, 1) = "ITEM NO."
      oSheet.Cells(1, 2) = "PO#"  DateBound.Requery
    If Not DateBound.EOF And Not DateBound.BOF Then
    DateBound.MoveFirst
    End If
         i = 1
     For i = 1 To DateBound.RecordCount oSheet.Cells(i + 1, 1) = IIf(DateBound!filed1 <> "", DateBound!productID, "")
     oSheet.Cells(i + 1, 2) = IIf(DateBound!field2 <> "", DateBound!orderID, "")
      DateBound.MoveNextNext 
             oExcel.Visible = True
             Set oSheet = Nothing
             Set oBook = Nothing
             Set oExcel = Nothing
             
        
    End Sub