To create a report for a Schedule object, create an instance of the Report class. This class along with the rest of the reporting classes are declared in the MindFusion.Scheduling.Reporting.dll assembly.
C# Copy Code |
---|
Report report = new Report(); |
VB.NET Copy Code |
---|
Dim report As New Report() |
The report is associated with Schedule objects through its Schedule property.
Each report contains zero or more columns. The columns in the report display individual properties of the items in the underlying Schedule, such as HeaderText, StartTime and so on. To add new columns to an existing report, call the CreateColumn method, set the desired properties of the ReportColumn object returned by this method, then add the column to the report's Columns collection. There is no limit to the number of columns a report can contain.
The following code creates two columns in the report, displaying the HeaderText and StartTime properties of the items respectively.
C# Copy Code |
---|
ReportColumn column = null; |
VB.NET Copy Code |
---|
Dim column As ReportColumn = Nothing |
The widths of the columns are interpreted differently depending on the AbsoluteColumnWidth property in the report's Options. By default, the name of the associated property is displayed as a header of each column. This header can be customized through the column's Header property or the report's QueryHeaderText event.
The reports can be customized through the properties in the ReportOptions class. An instance of this class can be accessed through the report's Options property. The following example sets the background of all even rows in the report to red:
C# Copy Code |
---|
report.Options.AlternativeStyle.Brush = new MindFusion.Drawing.SolidBrush(Color.Red); |
VB.NET Copy Code |
---|
report.Options.AlternativeStyle.Brush = New MindFusion.Drawing.SolidBrush(Color.Red) |
To print or preview a report, call its Print or Preview methods respectively. The report needs to be already associated with a Schedule object or these methods will raise an exception.
The reports can be exported to PDF and Excel by calling the ExportPdf and ExportExcel respectively. Each method accepts as argument the name of the file to export to. Once again, if the report is not associated with a Schedule, the methods will raise an exception.
The reports can also display items grouped by their associated resources. To enable grouping, set GroupType to ByContacts, ByResources, ByLocations or ByTasks, depending on the type of the resource to group by. The appearance of the resource header in the report can be customized through the GroupHeaderStyle property.