From Xojo Documentation

Revision as of 19:23, 21 November 2019 by Gperlman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


A component of the Reports module that provides the data access for the report.

EOF NextRecord
Field Run
Field Type


The DataSet interface enables you to use any dataset as the data source for the report. See the example for notes on how to set up the DataSet interface to use a text file as the data source.

To return Pictures for display in a report, you should return the Picture data rather than a Picture object. For example, if you have a Picture in variable p, then your would return the Picture data in the Field method like this:

Return p.GetData(Picture.FormatPNG)

Use a type of 14 to identify the Picture as data.


See the Gas Report example project that is included with Xojo. This example uses a text file as the data source for the report. It was added to the project and is named "Price_of_Gasoline". The DataSet interface is used to make the data available to the reporting engine. The GasDataSet class implements the DataSet interface. The following methods are used.


Sub Run()
// Part of the Reports.DataSet interface.
mData = SplitB(Price_of_Gasoline, ChrB(13))
mCurrentRecord = 0
End Sub


Sub Field(Name As String) As Variant
// Part of the Reports.DataSet interface.
Static months() As String = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun",_
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")

Var data() As String = SplitB(mData(mCurrentRecord), ",")

If name = "Year" Then
Return data(0)
Var idx As Integer = months.IndexOf(name)
If idx <> -1 Then Return data(idx + 1)
End If
Return Nil
End Sub


Sub NextRecord() As Boolean
// Part of the Reports.DataSet interface

mCurrentRecord = mCurrentRecord + 1
End Sub


Sub EOF() As Boolean
// Part of the Reports.DataSet interface.
If mCurrentRecord > mData.Ubound Then Return True

Return False
End Sub


// Part of the Reports.DataSet interface
Function Type(fieldname As String) As Integer
If fieldname = "Year"
Return // Text
Return 7 // Double
End if
End Function

See Also

Reports module; Report, ReportField, ReportLabel, ReportLineShape, ReportOvalShape, ReportRectangleShape, ReportRoundRectangleShape. ReportPicture classes; UserGuide:Displaying Desktop Reports topic