From Xojo Documentation

Class (inherits from Object)

Used to store the report pages after a report has been run. It is part of the Reports module.

PageCount fa-lock-32.png

Page Print


The RBReportDocument class is part of the Reports module. It returns the document after a report has been run. A report consists of one or more pages as Picture objects. You can refer to a page using its index. You can display the pages to the user in a Canvas control or print the pages.


See the modified Example Database project that returns both a simple report and report with a break level. See also the Gas Report project that prints a simple listing without a break levels.

In the Gas Report example project, the RBReportDocument returned by the reporting engine is passed to the instance of the Report class:

Var ds As New GasDataSet // Reports.DataSet object
Var ps As New PrinterSetup
Var rpt As New GasPricesReport

If rpt.Run(ds, ps) Then
If rpt.Document <> Nil Then ReportViewer1.SetDocument(rpt.Document)
End If

The SetDocument method gets the current page of the report so that it can be imaged.

Sub SetDocument(doc As Reports.RBReportDocument)
mDocument = doc
mCurrentPage = 1
If doc.PageCount > 0 Then SetCurrentPage(mCurrentPage)
End Sub

SetCurrentPage gets the picture of the current page.

Sub SetCurrentPage(pageNum As Integer)
mCurrentPage = pageNum
mCurrentPicture = mDocument.Page(mCurrentPage)
ScrollBar1.Maximum = mCurrentPicture.Height - Canvas1.Height
ScrollBar1.Value = 0
End Sub

The Paint event of the Canvas uses Graphics.DrawPicture to image the passed page.

Sub Paint(g As Graphics)
If mCurrentPicture <> Nil Then
g.DrawPicture(mCurrentPicture, 0, 0, Me.Width, Me.Height, 0, _
Scrollbar1.Value, Me.Width, Me.Height)
g.DrawRectangle(0, 0, Me.Width, Me.Height)
End If
End Sub

See Also

Reports module; Report class; UserGuide:Displaying Desktop Reports topic