This tutorial demonstrates how to setup and preview an event report in MindFusion.Scheduling.
To create a report, simply instantiate from the Report class.
C# Copy Code |
---|
Report report = new Report(); |
Visual Basic Copy Code |
---|
Dim report As new Report() |
Report columns are created by calling the CreateColumn method on the report object. Once created the column's properties can be customized as needed, then the columns are added to the report by calling the Add method of the ReportColumnCollection returned by the Columns property. The following code illustrates how to create three columns containing the header text, the start date and the end date of items respectively and how to add them to the report created in step 1.
C# Copy Code |
---|
ReportColumn column = null; |
Visual Basic Copy Code |
---|
Dim column As ReportColumn = Nothing |
We make the first column twice as wide as the other columns.
It is very important to associate the report with the schedule, which would provide the items for the report. If the report does not have an assigned schedule by the time its Preview or Print methods are invoked, the invocation would raise an exception. You associate a schedule with the report by assigning the schedule instance to the Schedule property of the report. The code below assumes that the variable schedule identifies a valid Schedule instance.
C# Copy Code |
---|
report.Schedule = schedule; |
Visual Basic Copy Code |
---|
report.Schedule = schedule |
You can customize various aspects of the report by modifying the properties of the ReportOptions object, accessed through the Report.Options property. In this particular case we will make the width of the columns in the report to resize to automatically fill the width of one page.
C# Copy Code |
---|
report.Options.AbsoluteColumnWidth = false; |
Visual Basic Copy Code |
---|
report.Options.AbsoluteColumnWidth = False |
The report is printed or previewed by calling the Print or Preview methods respectively. Both methods accept two .NET DateTime instances, which specify the time range of the items included in the report. If you do NOT have infinite recurrences in the report it is safe to specify DateTime.MinValue and DateTime.MaxValue for those parameters to ensure that all items will get included in the report.
C# Copy Code |
---|
report.Preview(DateTime.MinValue, DateTime.MaxValue); |
Visual Basic Copy Code |
---|
report.Preview(DateTime.MinValue, DateTime.MaxValue) |
Here is how our report would look like.