主要是使用PageDocument.Print方法进行直接打印
- Imports GrapeCity.ActiveReports
- Public Class Form1
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- '创建报表
- Dim rpt As GrapeCity.ActiveReports.PageReport
- rpt = New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo("PageReport1.rdlx"))
- '创建文档对象,并绑定数据源加载事件
- Dim doc As New GrapeCity.ActiveReports.Document.PageDocument(rpt)
- AddHandler doc.LocateDataSource, AddressOf mobjDocument_LocateDataSource
- '打印
- doc.Print(True)
- End Sub
- Private Sub mobjDocument_LocateDataSource(ByVal sender As Object, ByVal args As GrapeCity.ActiveReports.LocateDataSourceEventArgs)
- Try
- '加载数据源
- Dim dt As New DataTable
- dt.Columns.Add("Field1")
- dt.Columns.Add("Field2")
- dt.Columns.Add("Field3")
- dt.Rows.Add(1, 1, 1)
- dt.Rows.Add(2, 2, 2)
- dt.Rows.Add(2, 2, 2)
- dt.Rows.Add(2, 2, 2)
- dt.Rows.Add(2, 2, 2)
- args.Data = dt
- Catch ex As Exception
- Exit Sub
- End Try
- End Sub
- End Class
复制代码 |