All docs
V20.2
20.2 (EAP/Beta)
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
You are viewing help content for pre-release software. This document and the features it describes are subject to change.

Print and Export

  • 6 minutes to read
TIP

Demo: WPF Gantt Control - Printing

Requires a WPF Subscription. Download

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
GanttView.ShowPrintPreview Renders the View in a document and displays it in the Print Preview window.
GanttView.ShowPrintPreviewDialog Renders the View in a document and displays it in the modal Print Preview window.
GanttView.ShowRibbonPrintPreview Renders the View in a document and displays it in the Print Preview window with the Ribbon UI.
GanttView.ShowRibbonPrintPreviewDialog Renders the View in a document and displays it in the modal Print Preview window with the Ribbon UI.

To print GanttControl data, call one of the following methods:

Method Description
GanttView.Print Invokes the standard Print dialog that allows users to print the GanttControl.
GanttView.PrintDirect Uses the default printer to print the GanttControl.

Export Data in Code

You can use the following methods to export GanttControl data in code:

Format

Method

Export Area

PrintArea Value

Export Mode

PDF

GanttView.ExportToPDF

Entire Control / TreeList / Gantt

Any

WYSIWYG

Image

GanttView.ExportToImage

Entire Control / TreeList / Gantt

Any

WYSIWYG

XLS

GanttView.ExportToXls

TreeList

Ignored

Data-Aware

XLSX

GanttView.ExportToXlsx

TreeList

Ignored

Data-Aware

CSV

GanttView.ExportToCsv

TreeList

Ignored

Data-Aware

XPS

GanttView.ExportToXps

TreeList

TreeList

WYSIWYG

TXT

GanttView.ExportToText

TreeList

TreeList

WYSIWYG

DOCX

GanttView.ExportToDocx

TreeList

TreeList

WYSIWYG

RTF

GanttView.ExportToRtf

TreeList

TreeList

WYSIWYG

HTML

GanttView.ExportToHtml

TreeList

TreeList

WYSIWYG

MHT

GanttView.ExportToMht

TreeList

TreeList

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="(9/14/2020)-(9/25/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");
}

Customize Appearance

The printed GanttControl ignores regular Template/Style properties. The GanttControl's View has special Styles and Templates that define the printed document's appearance.

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>

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.

Printing Options

Property Description
GanttView.PrintArea Specifies whether to print the entire Gantt Area, the tree of tasks and subtasks, or the chart.
GanttView.PrintDateRange Specifies the date range for which to print tasks. Connectors for tasks outside the specified range are not printed.
GanttView.PrintGanttAreaScrollMargin Specifies the outer indents of the Gantt task area.
GanttView.PrintHeadersOnFirstPageOnly Specifies whether to print column headers only on the first page. If the GanttView.PrintArea is set to TreeList, column headers are printed on each page regardless of the PrintHeadersOnFirstPageOnly property value.
Show TreeList Area Properties
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.

Styles and Templates

Property Description
GanttView.PrintTaskStyle Specifies the style applied to tasks.
GanttView.PrintTaskBaselineStyle Specifies the style applied to task baselines.
GanttView.PrintSummaryTaskStyle Specifies the style applied to summary tasks.
GanttView.PrintSummaryTaskBaselineStyle Specifies the style applied to summary task baselines.
GanttView.PrintMilestoneStyle Specifies the style applied to milestones.
GanttView.PrintMilestoneBaselineStyle Specifies the style applied to milestone baselines.
GanttView.PrintConnectorStyle Specifies the style applied to connectors.
GanttView.PrintResourceStyle Specifies the style applied to resources.
GanttView.PrintGanttRowStyle Specifies the style applied to Gantt rows.
GanttView.PrintTimescaleRulerStyle Specifies the style applied to timescale rulers.
GanttView.PrintMarkedTimeIntervalsStyle Specifies the style applied to marked time intervals.
StripLineBase.PrintControlStyle Specifies the style applied to strip lines.
GanttView.PrintTaskContentTemplate, GanttView.PrintTaskContentTemplateSelector Specifies the template applied to task contents.
Show TreeList Area Styles and Templates
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.