主题:[原创]vb无法打印excel报表啊
Private Sub Command5_Click()
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim adors As New Recordset
Dim i As Integer
Set xlapp = New Excel.Application
xlapp.Visible = False
Set xlbook = xlapp.Workbook.Open(App.Path + "\" + "学生报表.xls")
Set xlsheet = xlbook.Worksheets(1)
adors.ActiveConnection = ADOcn
adors.Open "select*from 学生 order by XH"
i = 3
Do While Not adors.EOF
xlsheet.Cells(i, 1) = Trim(adors("XH"))
xlsheet.Cells(i, 2) = Trim(adors("XM"))
xlsheet.Cells(i, 3) = Trim(adors("XB"))
i = i + 1
adors.MoveNext
Loop
xlbook.Save
xlbook.Close
xlapp.Quit
MsgBox "报表以生成!", vbOKOnly, "信息提示"
End Sub
无法打印excel报表啊 Set xlbook = xlapp.Workbook.Open(App.Path + "\" + "学生报表.xls") 这句语言老是出错 请教高手 不知道哪里错了
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim adors As New Recordset
Dim i As Integer
Set xlapp = New Excel.Application
xlapp.Visible = False
Set xlbook = xlapp.Workbook.Open(App.Path + "\" + "学生报表.xls")
Set xlsheet = xlbook.Worksheets(1)
adors.ActiveConnection = ADOcn
adors.Open "select*from 学生 order by XH"
i = 3
Do While Not adors.EOF
xlsheet.Cells(i, 1) = Trim(adors("XH"))
xlsheet.Cells(i, 2) = Trim(adors("XM"))
xlsheet.Cells(i, 3) = Trim(adors("XB"))
i = i + 1
adors.MoveNext
Loop
xlbook.Save
xlbook.Close
xlapp.Quit
MsgBox "报表以生成!", vbOKOnly, "信息提示"
End Sub
无法打印excel报表啊 Set xlbook = xlapp.Workbook.Open(App.Path + "\" + "学生报表.xls") 这句语言老是出错 请教高手 不知道哪里错了