Print and Export
- 6 minutes to read
You can print and export the GanttControl. Use the GanttView.PrintArea property to specify whether to print/export the entire GanttControl, the TreeList area, or the Gantt area.
#Built-in Print Preview Window
The Print Preview window allows users to print a document or export it to a PDF/Image file.
To invoke the Print Preview window, call one of the following methods:
Method | Description |
---|---|
Gantt |
Renders the View in a document and displays it in the Print Preview window. |
Gantt |
Renders the View in a document and displays it in the modal Print Preview window. |
Gantt |
Renders the View in a document and displays it in the Print Preview window with the Ribbon UI. |
Gantt |
Renders the View in a document and displays it in the modal Print Preview window with the Ribbon UI. |
#Print Data in Code
To print GanttControl data, call one of the following methods:
Method | Description |
---|---|
Gantt |
Invokes the standard Print dialog that allows users to print the Gantt |
Gantt |
Uses the default printer to print the Gantt |
#Export Data in Code
You can use the following methods to export GanttControl data in code:
Format | Method | Export Area | Export Mode |
---|---|---|---|
Entire Control / Tree | WYSIWYG | ||
Image | Entire Control / Tree | WYSIWYG | |
XLS | Tree | Data-Aware | |
XLSX | Tree | Data-Aware | |
CSV | Tree | Data-Aware | |
XPS | Tree | WYSIWYG | |
TXT | Tree | WYSIWYG | |
DOCX | Tree | WYSIWYG | |
RTF | Tree | WYSIWYG | |
HTML | Tree | WYSIWYG | |
MHT | Tree | WYSIWYG |
#WYSIWYG Export
WYSIWYG Export methods use the Printing-Exporting library to export data. An exported document retains the layout and appearance of Gantt elements. The following formats are supported:
- PDF - the entire GanttControl or its areas (TreeList / Tasks and Timeline).
- Image (BMP, EMF, WMF, GIF, JPEG, PNG, TIFF) - the entire GanttControl or its areas (TreeList / Tasks and Timeline).
- XPS, TXT, DOCX, RTF, HTML, MHT - TreeList only.
<dxgn:GanttControl ItemsSource="{Binding Tasks}">
<dxgn:GanttControl.View>
<dxgn:GanttView PrintArea="EntireControl"
PrintDateRange="(10/5/2020)-(10/18/2020)"
x:Name="ganttView"/>
</dxgn:GanttControl.View>
</dxgn:GanttControl>
void ExportData(object sender, System.Windows.RoutedEventArgs e) {
ganttView.ExportToPdf(@"c:\Examples\gantt_export.pdf");
}
#Data-Aware Export
Data-Aware export methods allow users to process exported data in Microsoft Excel. The GanttControl ignores the GanttView.PrintArea property value and exports its TreeList area only.
void ExportData(object sender, System.Windows.RoutedEventArgs e){
ganttView.ExportToXlsx(@"c:\Examples\gantt_export.xlsx");
}
#Printing Options
Property | Description |
---|---|
Gantt |
Specifies whether to print the entire Gantt Area, the tree of tasks and subtasks, or the chart. |
Gantt |
Specifies the date range for which to print tasks. Connectors for tasks outside the specified range are not printed. |
Gantt |
Specifies the outer indents of the Gantt task area. |
Gantt |
Specifies whether to print column headers only on the first page. If the Gantt |
Property | Description |
---|---|
GanttView.PrintAutoWidth | Specifies whether to change the TreeList area’s width to fit the page. |
GanttView.PrintBandHeaders | Specifies whether to print band headers. |
GanttView.PrintColumnHeaders | Specifies whether to print column headers. |
GanttView.PrintExpandButtons | Specifies whether to print expand buttons. |
GanttView.PrintNodeImages | Specifies whether to print node images. |
GanttView.AllowPrintColumnHeaderImage | Specifies whether to print column header images. |
GanttView.PrintRootIndent | Specifies whether to print expand buttons. |
GanttView.PrintRowIndentWidth | Specifies whether to print an indent for the root node. |
GanttView.PrintSelectedRowsOnly | Specifies whether to print only the selected rows. |
GanttView.PrintTotalSummary | Specifies whether to print the Summary Panel. |
GanttView.PrintFixedTotalSummary | Specifies whether to print the Fixed Summary Panel. |
GanttView.PrintAllNodes | Specifies whether to expand all nodes in the printed document. |
GanttColumn.AllowPrinting | Specifies whether to display the column in the printed/exported document. |
#Customize Appearance
The printed GanttControl ignores regular Style and Template properties. The GanttControl‘s View has special Styles and Templates that define the printed document’s appearance.
Property | Description |
---|---|
Gantt |
Specifies the style applied to tasks. |
Gantt |
Specifies the style applied to task baselines. |
Gantt |
Specifies the style applied to summary tasks. |
Gantt |
Specifies the style applied to summary task baselines. |
Gantt |
Specifies the style applied to milestones. |
Gantt |
Specifies the style applied to milestone baselines. |
Gantt |
Specifies the style applied to connectors. |
Gantt |
Specifies the style applied to resources. |
Gantt |
Specifies the style applied to Gantt rows. |
Gantt |
Specifies the style applied to timescale rulers. |
Gantt |
Specifies the style applied to marked time intervals. |
Strip |
Specifies the style applied to strip lines. |
Gantt |
Specifies the template applied to task contents. |
Property | Description |
---|---|
GanttView.PrintBandHeaderStyle | Specifies the style applied to band headers. |
GanttView.PrintColumnHeaderStyle | Specifies the style applied to column headers. |
GanttView.PrintCellStyle | Specifies the style applied to data cells. |
GanttView.PrintRowIndentStyle | Specifies the style applied to row indents. |
GanttView.PrintTotalSummaryStyle | Specifies the style applied to the Summary Panel. |
GanttView.PrintFixedTotalSummaryStyle | Specifies the style applied to the Fixed Summary Panel. |
GanttColumn.PrintCellStyle | Specifies the style applied to the column’s data cells. |
GanttColumn.PrintColumnHeaderStyle | Specifies the style applied to the column header. |
GanttColumn.PrintTotalSummaryStyle | Specifies the style applied to the column’s total summary. |
GanttColumn.ActualPrintTotalSummaryStyle | Returns the style applied to the column’s total summary. |
GanttColumn.ActualPrintCellStyle | Returns the style applied to the column’s data cells. |
GanttColumn.ActualPrintColumnHeaderStyle | Returns the style applied to the column header. |
GanttView.PrintRowTemplate | Specifies the template applied to data rows. |
GanttView.PrintHeaderTemplate | Specifies the template applied to column headers. |
GanttView.PrintFooterTemplate | Specifies the template applied to the Summary Panel. |
GanttView.PrintFixedFooterTemplate | Specifies the template applied to the Fixed Summary Panel. |
For information on how to customize the GanttControl‘s TreeList area, refer to the Printing and Exporting topic in documentation for the DevExpress WPF Grid.
#Example: Change the Printed GanttControl Appearance
<Window xmlns:dxgn="http://schemas.devexpress.com/winfx/2008/xaml/gantt"
xmlns:dxgnn="http://schemas.devexpress.com/winfx/2008/xaml/gantt/internal">
<Window.Resources>
<Style x:Key="customPrintTimescaleRulerStyle" TargetType="{x:Type dxgnn:TimescaleRulerControl}">
<Setter Property="Background" Value="White"/>
</Style>
<Style x:Key="customPrintMilestoneStyle" TargetType="{x:Type dxgn:GanttMilestoneControl}">
<Setter Property="Background" Value="#0173C7"/>
</Style>
<Style x:Key="customPrintMilestoneBaselineStyle" TargetType="{x:Type dxgn:GanttMilestoneBaselineControl}">
<Setter Property="Background" Value="Gray"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Opacity" Value=".5"/>
</Style>
<Style x:Key="customPrintTaskBaselineStyle" TargetType="{x:Type dxgn:GanttTaskBaselineControl}">
<Setter Property="Background" Value="Gray"/>
<Setter Property="Opacity" Value=".5"/>
</Style>
<Style x:Key="customPrintSummaryTaskBaselineStyle" TargetType="{x:Type dxgn:GanttSummaryTaskBaselineControl}">
<Setter Property="Background" Value="Gray"/>
<Setter Property="Opacity" Value=".5"/>
</Style>
</Window.Resources>
<dxgn:GanttControl ItemsSource="{Binding Tasks}" ...>
<dxgn:GanttControl.View>
<dxgn:GanttView PrintArea="Gantt"
PrintDateRange="(9/15/2020)-(9/25/2020)"
PrintTimescaleRulerStyle="{StaticResource customPrintTimescaleRulerStyle}"
PrintMilestoneStyle="{StaticResource customPrintMilestoneStyle}"
PrintMilestoneBaselineStyle="{StaticResource customPrintMilestoneBaselineStyle}"
PrintTaskBaselineStyle="{StaticResource customPrintTaskBaselineStyle}"
PrintSummaryTaskBaselineStyle="{StaticResource customPrintSummaryTaskBaselineStyle}"/>
</dxgn:GanttControl.View>
...
</dxgn:GanttControl>
</Window>