|
本帖最后由 todaynew 于 2009-3-14 16:02 编辑
Private Sub Command0_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim rs As New ADODB.Recordset
Dim sql As String
Dim i As Long
sql = "select * from 456"
rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Set xlApp = CreateObject("Excel.Application")
xlApp.Application.Visible = True
Set xlBook = xlApp.Workbooks.Open(CurrentProject.Path & "\Book1.xls")
xlBook.Application.Sheets(1).Select
For i = 1 To rs.RecordCount
xlBook.Application.Cells(i + 1, 1).Value = rs("日期")
xlBook.Application.Cells(i + 1, 2).Value = rs("采购数量")
xlBook.Application.Cells(i + 1, 3).Value = rs("采购单价")
xlBook.Application.Cells(i + 1, 4).Value = rs("采购总价值")
rs.MoveNext
Next
xlApp.Quit
Set xlApp = Nothing
Set xlBook = Nothing
End Sub |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|