Skip to main content

Printing and Exporting

  • 3 minutes to read

The DXPivotGrid Suite for Silverlight supports client-side printing and server-side exporting. Key features include:

  • Complete customization of pivot grid fields and cells in a printed document via templates and styles;
  • An advanced Print Preview control;
  • Supported export formats: PDF, XLS, XLSX, RTF, XPS, TXT, CSV, MHT, HTML, Image (PNG, BMP, etc.).

Requirements:

  • DevExpress.Xpf.Printing.v14.2.dll assembly.

#Printing Options and Settings

PivotGridControl provides multiple options, styles and templates that allow you to customize the printed document.

The following table lists printing options.

Property Description
PivotGridControl.PrintColumnHeaders Gets or sets whether to print headers of the column fields. This is a dependency property.
PivotGridControl.PrintDataHeaders Gets or sets whether to print headers of the data fields. This is a dependency property.
PivotGridControl.PrintFilterHeaders Gets or sets whether to print headers of the filter fields. This is a dependency property.
PivotGridControl.PrintHeadersOnEveryPage Gets or sets whether to print field headers on every page. This is a dependency property.
PivotGridControl.PrintHorzLines Gets or sets whether the horizontal grid lines are printed. This is a dependency property.
PivotGridControl.PrintInsertPageBreaks Gets or sets whether to insert page breaks at the end of every page. This is a dependency property.
PivotGridControl.PrintLayoutMode Gets or sets the layout mode of the print document. This is a dependency property.
PivotGridControl.PrintRowHeaders Gets or sets whether to print headers of the row fields. This is a dependency property.
PivotGridControl.PrintUnusedFilterFields Gets or sets whether to print headers of the unused filter fields. This is a dependency property.
PivotGridControl.PrintVertLines Gets or sets whether the vertical grid lines are printed. This is a dependency property.

The following table lists templates applied to PivotGridControl elements when they are printed.

Property

Description

PivotGridControl.PrintFieldCellTemplate

PivotGridControl.PrintFieldCellTemplateSelector

PivotGridControl.PrintFieldCellKpiTemplate

PivotGridControl.PrintFieldCellKpiTemplateSelector

PivotGridField.PrintCellTemplate

PivotGridField.PrintCellTemplateSelector

Specifies a template that defines the presentation of data cells when the pivot grid is printed.

PivotGridControl.PrintFieldHeaderTemplate

PivotGridControl.PrintFieldHeaderTemplateSelector

PivotGridField.PrintHeaderTemplate

PivotGridField.PrintHeaderTemplateSelector

Specifies a template that defines the presentation of field headers when the pivot grid is printed.

PivotGridControl.PrintFieldValueTemplate

PivotGridControl.PrintFieldValueTemplateSelector

PivotGridField.PrintValueTemplate

PivotGridField.PrintValueTemplateSelector

Specifies a template that defines the presentation of field values when the pivot grid is printed.

#Displaying a Print Preview

End-users can print and export a pivot grid using a Print Preview control.

To display a Print Preview, do the following:

  1. Add a reference to the DevExpress.Xpf.Printing.v14.2.dll assembly.
  2. Add an export service for passing an exported pivot grid to a Silverlight client.

    PrintExport_AddItem

    PrintExport_ExportService

  3. Add code that displays a Print Preview.

    
    using DevExpress.Xpf.Printing;
    
    //...
    
    private void ShowPrintPreview(PivotGridControl pivotgrid) {
        DocumentPreviewWindow preview = new DocumentPreviewWindow();
        PrintableControlLink link = new PrintableControlLink(pivotgrid as IPrintableControl);
        link.ExportServiceUri = "../ExportService1.svc";
        LinkPreviewModel model = new LinkPreviewModel(link);
        preview.Model = model;
        link.CreateDocument(true);
        preview.ShowDialog();
    }
    

     

    The ShowPrintPreview method invokes a Print Preview shown in the following image.

    PrintPreview