DataSet
From Xojo Documentation
A component of the Reports module that provides the data access for the report.
Methods | ||||||
|
Notes
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:
Use a type of 14 to identify the Picture as data.
Examples
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.
Run
// Part of the Reports.DataSet interface.
mData = SplitB(Price_of_Gasoline, ChrB(13))
mCurrentRecord = 0
End Sub
Field
// 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)
Else
Var idx As Integer = months.IndexOf(name)
If idx <> -1 Then Return data(idx + 1)
End If
Return Nil
End Sub
NextRecord
// Part of the Reports.DataSet interface
mCurrentRecord = mCurrentRecord + 1
End Sub
EOF
// Part of the Reports.DataSet interface.
If mCurrentRecord > mData.Ubound Then Return True
Return False
End Sub
Type
Function Type(fieldname As String) As Integer
If fieldname = "Year"
Return // Text
Else
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