Tutorial: Printing and Exporting a Pivot Grid

  • 3 minutes to read

This document acquaints you with the printing and exporting capabilities provided by DXPivotGrid.

In this lesson, use the application you have created in Lesson 1.

This tutorial will guide you through the following steps:

Step 1. Customize Print Options

First, let's take a look at the PivotGridControl print options. You can find them in the Print Options section of the Properties window.

GettingStarted_L3_01

Here you can access multiple settings that allow you to customize a printing report to be generated out of the pivot grid. For instance, you can specify which visual elements (like field headers and grid lines) should be printed and whether to use a single-page or a multiple-pages layout mode (see PivotGridControl.PrintLayoutMode for details).

Step 2. Show Print Preview

To see the pivot grid printing capabilities in action, add a standard button to your WPF application and set the button caption to Print Preview.

GettingStarted_L3_03

To invoke a pivot grid Print Preview, call the PivotGridControl.ShowPrintPreview method in the button click event handler.

private void button1_Click(object sender, RoutedEventArgs e) {
    string DocumentName="Preview Document";
    string Title="Print Preview";
    pivotGridControl1.ShowPrintPreview(this, DocumentName, Title);
}

Now run the project and click Print Preview to see the print report.

GettingStarted_L3_04

You can navigate through report pages by clicking the Next Page button on a navigation bar.

GettingStarted_L3_05

To print this report using a local printer, use the Print toolbar button.

GettingStarted_L3_06

Step 3. Customize Export Options

You can also use the Print Preview dialog to export pivot grid data into numerous popular formats. To do this, use the Export Document button. Click the button's down arrow to display a drop-down menu that allows you to choose a required file format.

GettingStarted_L3_07

After you select a format, an export options window will be invoked allowing you to customize format-specific settings. For example, for HTML you can specify whether to export a report into a single HTML file without breaking it into pages (Single file export mode), preserve a page-by-page breakdown in the resultant file (Single file page-by-page export mode), or generate individual HTML files for each page of the report (Different files export mode).

GettingStarted_L3_08

If you choose to create individual HTML files for each page or preserve page-by-page breakdown while exporting to a single file, you will be able to specify page settings like the color and width of page borders.

GettingStarted_L3_09

Similarly to HTML, if you select a simple format (e.g. CSV), you will be able to access its specific options like text encoding and export mode.

GettingStarted_L3_10

Now click OK and choose the destination where the file should be saved using a standard file save dialog.

See Also