Skip to main content

How to: Export the View's Data in PDF Format

The following example demonstrates how to export data displayed by a grid control’s main View as a PDF. To export data, the BaseView.ExportToPdf method, requiring the XtraPrinting Library, is used.

In the example, the GridOptionsPrint.ExpandAllDetails option is set to true. Note that this setting is in effect only when the GridOptionsPrint.PrintDetails property is set to true. This ensures that if the main View represents a master view, all its rows will be expanded in the output file.

DevExpress.XtraGrid.Views.Grid.GridView View = gridControl1.MainView
   as DevExpress.XtraGrid.Views.Grid.GridView;
if (View != null) {
   View.OptionsPrint.ExpandAllDetails = true;
   View.ExportToPdf("MainViewData.pdf");
}