Skip to main content
A newer version of this page is available. .

Printing

  • 4 minutes to read

The PivotGridControl provides a fast and flexible way of bringing its contents to a printed page.

cdPrinting

This topic demonstrates how to customize the printed version of the Pivot Grid Control, and lists the ways in which the pivot grid control can be printed. The document comprises the following subsections:

Note

Custom painting, alpha blending and color gradient features are not supported in the pivot grid control’s printout.

Printing Basics

The Pivot Grid control provides its own methods to print displayed data, but these methods delegate the printing functionality to the DevExpress Printing Library. If this library cannot be found, the printing and exporting functionality is not available. To ensure that the Pivot Grid control can be printed/exported, check the PivotGridControl.IsPrintingAvailable property’s value.

To print data from the Pivot Grid control, use the following methods.

Member Description
PivotGridControl.Print Prints the PivotGridControl.
PivotGridControl.ShowPrintPreview Opens the Print Preview window with a toolbar-based interface.
PivotGridControl.ShowRibbonPrintPreview Opens the Print Preview window with a Ribbon-based interface.

These methods print and show a print preview of the data displayed by the Pivot Grid control.

The following code snippet demonstrates how to display a Print Preview Ribbon window.

private void ShowPivotGridPreview(DevExpress.XtraPivotGrid.PivotGridControl pivotGrid) {
   // Check whether the Pivot Grid control can be printed.
   if(!pivotGrid.IsPrintingAvailable) {
      MessageBox.Show("Missing DevExpress.XtraPrinting library", "Error");
      return;
   }
   // Invokes the Preview window.
   pivotGrid.ShowRibbonPrintPreview();
}

The image below illustrates the Preview window for a sample pivot grid.

cdPrintData_main

Refer to the XtraPrinting Library documentation for more information on the functionality provided by the print preview window.

Modifying Print Appearances

By default, a printed pivot grid utilizes the same appearances as when it is displayed on screen. These appearance settings can be customized using the PivotGridControl.Appearance property. However, a Pivot Grid provides print appearances used to paint the pivot grid’s visual elements (field headers, data cells, etc.) in print output. To use print appearances instead of display appearances when the pivot grid is printed, set the PivotGridOptionsPrint.UsePrintAppearance option to true.

Use the pivot grid’s PivotGridControl.AppearancePrint property to set print appearances. This property provides access to the appearance settings for various Pivot Grid elements (for example, fields, data cells, etc.).

PivotGrid-AppearancePrint

The appearance settings can be customized in the Print Appearances page of the PivotGrid Designer as well. You can save these settings to or restore these settings from an XML file.

PrintAppearancePage

Printing Options

The Pivot Grid provides a set of options that specify the Pivot Grid’s elements to be printed, as well as the appearance settings to be used to paint these elements when the pivot grid control is printed. These options can be accessed as follows.

  • At design time using the Print Settings page of the PivotGrid Designer.

    PrintingSettings_1

  • In code, using the PivotGridControl.OptionsPrint property.

    PivotGrid-OptionsPrint

  • By an end-user at runtime in the Print Options dialog invoked by clicking the “Options” menu command in the Preview window.

    PivotGrid-Print-options-EU

Example: How to Print a PivotGrid and Show its Print Preview

The following example demonstrates how to print the Pivot Grid control using the PivotGridControl.Print method and show its Print Preview window using the PivotGridControl.ShowPrintPreview method.

Note

Printing functionality depends on the DevExpress.XtraPrinting library. To verify that the library is available, use the PivotGridControl.IsPrintingAvailable property.

You can access print settings and modify them using the PivotGridControl.OptionsPrint property.

using DevExpress.XtraPivotGrid;
// ...

private void ShowPivotGridPreview(PivotGridControl pivotGrid) {
    // Verify that the Pivot Grid Control can be printed.
    if (!pivotGrid.IsPrintingAvailable) {
        MessageBox.Show("Missing DevExpress.XtraPrinting library", "Error");
        return;
    }
    pivotGrid.ShowPrintPreview();
}

private void PrintPivotGrid(PivotGridControl pivotGrid) {
    // Verify that the Pivot Grid Control can be printed.
    if (!pivotGrid.IsPrintingAvailable) {
        MessageBox.Show("Missing DevExpress.XtraPrinting library", "Error");
        return;
    }
    pivotGrid.Print();
});
}
See Also