Difference between revisions of "Report.Run"

From Xojo Documentation

(SMBot: new page by automated transformation)
 
(Sample Code: Changed deprecated ShowPrinterDialog(ps, Nil) to ps.ShowPrinterDialog(Nil))
 
(13 intermediate revisions by 6 users not shown)
Line 8: Line 8:
 
| platform=all
 
| platform=all
 
}}
 
}}
Generates a report document from the given dataset.
+
{{Description
 +
|text  = Generates a report document from the given dataset. }}
 +
 
 +
{{MethodBox
 +
| name = Run
 +
| owner = [[Report]]
 +
| ownertype = class
 +
| scope = public
 +
| parameters = rs as [[RowSet]], printerSettings as [[PrinterSetup]]
 +
| returntype = [[Boolean]]
 +
| newinversion = 2019r3
 +
}}
 +
{{Description | text=Generates a [[Report]] document from the given [[RowSet]]. }}
 +
 
 +
{{DeprecatedItem | version=2019r3 | replacement=Report.Run with a RowSet}}
 +
{{MethodBox
 +
| name = Run
 +
| owner = [[Report]]
 +
| ownertype = class
 +
| scope = public
 +
| parameters = rs as [[RecordSet]], printersettings as [[PrinterSetup]]
 +
| returntype = [[Boolean]]
 +
| newinversion = 2010r3
 +
}}
 +
{{Description
 +
| text=Generates a [[Report]] document from the given [[RecordSet]]. This eliminates the need to first convert a [[RecordSet]] to a [[RecordSetQuery]].
 +
}}
 +
 
 +
== Sample Code ==
 +
Running a report to obtain the rendered pages in [[Reports]].[[DataSet]]:
 +
 
 +
<rbcode>
 +
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
 +
</rbcode>
 +
 
 +
This generates and prints a report:
 +
<rbcode>
 +
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
 +
</rbcode>
 +
 
 +
 
 +
This generates and prints multiple copies of a report:
 +
<rbcode>
 +
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
 +
</rbcode>

Latest revision as of 21:49, 27 January 2021

Method

Report.Run(ds as Reports.DataSet, printerSettings as PrinterSetup) As Boolean

Supported for all project types and targets.

Generates a report document from the given dataset.


Method

Report.Run(rs as RowSet, printerSettings as PrinterSetup) As Boolean

New in 2019r3

Supported for all project types and targets.

Generates a Report document from the given RowSet.


Method

Report.Run(rs as RecordSet, printersettings as PrinterSetup) As Boolean

New in 2010r3

Supported for all project types and targets.

Generates a Report document from the given RecordSet. This eliminates the need to first convert a RecordSet to a RecordSetQuery.

Sample Code

Running a report to obtain the rendered pages in Reports.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 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 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