How to report custom data from a simple App
The following post describes the steps involved for creating a simple App which collects user data and uses it to produce a custom report embedded in the app project.


The project contains 3 modules: the app itself, a code module containing global data and the report.
The main purpose of the Globals module is to expose a DataTable object that will be used to communicate user input to the report engine.


The project contains 3 modules: the app itself, a code module containing global data and the report.
The main purpose of the Globals module is to expose a DataTable object that will be used to communicate user input to the report engine.
Private _dataTable As System.Data.DataTable
' The data table used in the report is created on demand.
Public ReadOnly Property DataTable As System.Data.DataTable
Get
If _dataTable Is Nothing Then
_dataTable = New System.Data.DataTable
_dataTable.Columns.Add("User",GetType(String))
_dataTable.Columns.Add("Batch",GetType(String))
_dataTable.Columns.Add("Sample",GetType(String))
End If
Return _dataTable
End Get
End Property
' This method transfers the data into the data table used by the report
Public Sub FillReportData(user As String,batch As String,sample As String)
DataTable.Rows.Clear
_dataTable.Rows.Add(New Object() {user,batch,sample})
End SubThis same table is then used in the code behind the report when processing the RefreshSchema event. Note that this event is used both when designing the report template and when creating a report, so that custom fields are visible when editing the template.Public Class AppReport
' This event is used to provide the custom datatable to the report engine
Private Sub ThisReport_RefreshSchema(ByVal source As Object, ByVal args As MediaCy.Addins.Reporter.ReportEventArgs) Handles ThisReport.RefreshSchema
args.Report.DataSources.Add("AppData",DataTable)
End Sub
End Class
Finally the App only has to call FillReportData, Private Sub btnReport_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btnReport.Click
FillReportData(txtUser.text,txtBatch.Text,txtSample.Text)
RunReport(cbOutput.SelectedIndex)
End Sub
and then use RunReport to create the report using standard reporting commands. Case ReportOutput.PreviewEdit
With Share.ReportCommands.Create(Nothing)
.Template = "SimpleAppReport>AppReport.iprt"
.ReadOnly=False
.Run(New Object(){ThisApplication.ActiveWindow}, Nothing)
End WithThe full project package is attached.0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions