我知道在VB中使用像datagrid之类的控件可以生成一个很想word或者说是excel样子的表格来显示数据,那可不可以将这些显示在datagrid中的数据直接导出到word或者excel中去呢,如果可以,大家指点我一下好吗,谢谢

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/2883/2883385.xml?temp=2.970523E-02
      

  2.   

    http://expert.csdn.net/Expert/topic/2883/2883385.xml?
      

  3.   

    Dim rs As ADODB.Recordset '数据集
    Dim newxls As Excel.Application 'Excel 应用程序
    Dim newbook As Excel.Workbook '工作薄
    Dim newsheet As Excel.Worksheet '工作表
    Private Sub Command1_Click()
    Set newxls = CreateObject("Excel.Application")
    newxls.Visible = True
    Set newbook = newxls.Workbooks.Add '创建工作薄
    Set newsheet = newxls.Worksheets.Add
    For i = 0 To rs.RecordCount - 1
        For j = 0 To rs.Fields.Count - 1
            DataGrid1.row = i
            DataGrid1.col = j
            newsheet.Cells(i + 4, j + 1) = DataGrid1.Text
        Next j
    Next i
    End Subrs没有定义你应该有定义!