用Excel作关键字搜索CSDN的帖子,你会找到许多相关内容

解决方案 »

  1.   

    申明一个Excel应用程序对象,并用它打开一个你要的文件,就可以完全控制Excel,如果查询,统计建议用ADO对象或控件打开Excel文档,在执行SQL语句完成
      

  2.   

    下面是将表格控件中的数据写到EXCEL中的一段代码,希望对你有所帮助!Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlSheet As Excel.Worksheet
    Dim tmpRow As Long
    Dim tmpCol As Integer
    On Error GoTo ExcelError    Screen.MousePointer = vbArrowHourglass
        If khyGrid.Cols = 2 Or khyGrid.Rows = 3 Then
           MsgBox "数据格式不对,请计算后再保存", vbOKCancel, "保存提示"
           Exit Sub
        Else
            Set xlApp = CreateObject("excel.application")
            Set xlBook = xlApp.Workbooks.Add
            Set xlSheet = xlBook.Sheets(1)
            For tmpRow = 0 To khyGrid.Rows - 1
                For tmpCol = 0 To khyGrid.Cols - 1
                    tmpTz = DoEvents()
                    If tmpBreak = True Then
                        tmpBreak = False
                        Exit Sub
                    End If
                    s = khyGrid.TextArray(rocos(tmpRow, tmpCol, khyGrid.Cols))
                    xlSheet.Cells(tmpRow + 1, tmpCol + 1) = s
                Next
            Next
            xlApp.Visible = True
            Screen.MousePointer = 0
            Exit Sub
        End If