Class

Report


Description

Used to generate reports.

Properties

Name

Type

Read-Only

Shared

DataSource

Reports.Dataset

Footer

RBReportSection

FooterTop

Integer

Group

RBReportGroup

Header

RBReportSection

Methods

Name

Parameters

Returns

Shared

AddFooter

sectionToAdd As RBReportSection

AddGroup

groupToAdd As RBReportGroup

AddHeader

sectionToAdd As RBReportSection

Close

Constructor

defaultunits As Reports.Units = Reports.Units.Pixels

Destructor

Document

RBReportDocument

Run

rs As recordset, pdf As PDFDocument

Boolean

rs As recordset, printersettings As PrinterSetup

Boolean

ds As Reports.Dataset, pdf As PDFDocument

Boolean

ds As Reports.Dataset, printersettings As PrinterSetup

Boolean

rs As RowSet, pdf As PDFDocument

Boolean

rs As RowSet, printerSettings As PrinterSetup

Boolean

Units

Reports.Units

Property descriptions


Report.DataSource

DataSource As Reports.Dataset

The source of the data for the report.

Report.Footer

Footer As RBReportSection

The section at the bottom of each page of a report.


Report.FooterTop

FooterTop As Integer

The vertical location on the page of the top of the footer.

This property is read-only.


Report.Group

Group As RBReportGroup

The last Group added to the report via the AddGroup method.


Report.Header

Header As RBReportSection

The section at the top of each page of a report.

Method descriptions


Report.AddFooter

AddFooter(sectionToAdd As RBReportSection)

Adds the passed footer to the report.


Report.AddGroup

AddGroup(groupToAdd As RBReportGroup)

Adds the passed group to the report.


Report.AddHeader

AddHeader(sectionToAdd As RBReportSection)

Adds the passed header to the report.


Report.Close

Close

Sets all Report controls to Nil.


Report.Constructor

Constructor(defaultUnits As Reports.Units = Reports.Units.Pixels)

Creates a new Report in the passed unit. The default is Reports.Units.Pixels.

Note

Constructors are special methods called when you create an Object With the New keyword And pass In the parameters above.


Report.Destructor

Destructor

Called when the Report object is about to be go out of scope or has been set to Nil.


Report.Document

Document As RBReportDocument

Returns the rendered pages after the Report is Run.

The document returned is the object you print to render the report to PDF or the printer.

This example runs a Report to obtain the rendered pages in a Dataset:

Var ds As New GasDataSet
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

Report.Run

Run(ds As Reports.Dataset, pdf As PDFDocument) As Boolean

Creates the report as a PDFDocument using the Reports.Dataset passed.

This eliminates the need to first convert a RowSet to a Report.


Report.Run

Run(ds As Reports.Dataset, printerSettings As PrinterSetup) As Boolean

Creates the report using the Reports.Dataset passed.

This eliminates the need to first convert a RowSet to a Report.


Report.Run

Run(rs As RowSet, pdf As PDFDocument) As Boolean

Creates the report as a PDFDocument using the RowSet passed.

This eliminates the need to first convert a RowSet to a Report.


Report.Run

Run(rs As RowSet, printerSettings As PrinterSetup) As Boolean

Creates the report using the RowSet passed.

This eliminates the need to first convert a RowSet to a Report.


Report.Units

Units As Reports.Units

Returns the unit of measure for the report.

Sample code

This example runs a Report to obtain the rendered pages in a Dataset:

Var rpt As New ListOfProducts
Var rs As RowSet = ordersDB.SelectSQL(sql)
Var ps As New PrinterSetup

If rpt.Run(rs, ps) Then
  If rpt.Document <> Nil Then
    ShowReport(rpt.Document)
  End If
End If

This example generates and prints a Report:

Var rpt As New MyReport ' A report in the project
Var ps As New PrinterSetup

Var g As Graphics
g = ps.ShowPrinterDialog(Nil)

If g <> Nil Then
  If Not rpt.Run(data, ps) Then ' data is the report data
    rpt.Document.Print(g)
  Else
    MessageBox("There was an error generating the report.")
  End If
End If

This example generates and prints multiple copies of a Report:

Var rpt As New MyReport ' A report in the project
Var ps As New PrinterSetup

Var g As Graphics
g = ps.ShowPrinterDialog(Nil)

Var readyToPrint As Boolean = True
If g <> Nil Then
  For copies As Integer = 1 To 2 ' Number of copies
    If Not rpt.Run(data, ps) Then ' data is the report data
      readyToPrint = False
    End If
  Next

  ' Print the results
  If readyToPrint Then
    rpt.Document.Print(g)
  Else
    MessageBox("There was an error generating the report.")
  End If
End If

Compatibility

All projects types on all supported operating systems.