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 |
---|---|
Pivot |
Gets or sets whether to print headers of the column fields. This is a dependency property. |
Pivot |
Gets or sets whether to print headers of the data fields. This is a dependency property. |
Pivot |
Gets or sets whether to print headers of the filter fields. This is a dependency property. |
Pivot |
Gets or sets whether to print field headers on every page. This is a dependency property. |
Pivot |
Gets or sets whether the horizontal grid lines are printed. This is a dependency property. |
Pivot |
Gets or sets whether to insert page breaks at the end of every page. This is a dependency property. |
Pivot |
Gets or sets the layout mode of the print document. This is a dependency property. |
Pivot |
Gets or sets whether to print headers of the row fields. This is a dependency property. |
Pivot |
Gets or sets whether to print headers of the unused filter fields. This is a dependency property. |
Pivot |
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 |
---|---|
Pivot Pivot Pivot Pivot | Specifies a template that defines the presentation of data cells when the pivot grid is printed. |
Pivot Pivot | Specifies a template that defines the presentation of field headers when the pivot grid is printed. |
Pivot Pivot | 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:
- Add a reference to the DevExpress.Xpf.Printing.v14.2.dll assembly.
Add an export service for passing an exported pivot grid to a Silverlight client.
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.