Printing and Exporting
- 8 minutes to read
Print or Export a Dashboard in the UI
To print or export the entire dashboard, click the Export To button in the dashboard title area and choose the format.
- Print Preview
The button invokes a Print Preview dialog that allows you to specify print options and print the dashboard:
- Export to PDF
Invokes a dialog that allows end-users to export a dashboard to a PDF file. The following options are available:
- Page Layout - Specifies the page orientation used to export a dashboard. You can select between Portrait, Landscape, and Auto. Note that in the Auto mode, page orientation is selected automatically depending on the horizontal and vertical sizes of a dashboard.
- Size - Specifies the standard paper size (for instance, Letter or A4).
- Show Title - Specifies whether to apply the dashboard title to the exported document title.
- Title - Specifies the title of the exported document.
- Scale Mode - Specifies the mode for scaling when exporting a dashboard.
Note
Note that this option is in effect when Page Layout is set to a value different from Auto.
- Scale Factor - Specifies the scale factor (in fractions of 1) by which a dashboard is scaled.
Note
This option is in effect if Scale Mode is set to Use Scale Factor.
- Auto Fit Page Count - Specifies the number of horizontal/vertical pages that span the total width/height of a dashboard.
Note
This option is in effect if Scale Mode is set to Auto Fit to Page Width.
- Include Filters - Allows you to include master filter values to the exported document.
- Include Parameters - Allows you to include parameter values to the exported document.
- Position - Specifies the position of the master filter and parameter values in the exported document. You can select between Below and Separate Page.
Specify the required options in this dialog and click Export to export the dashboard. To reset changes to the default values, click the Reset button.
- Export to Image
Invokes a dialog that allows end-users to export a dashboard to an image in the specified format. The following options are available:
- Image Format - Specifies the image format in which the dashboard is exported. The following formats are available: PNG, JPEG, and GIF.
- Show Title - Specifies whether to apply the dashboard title to the exported document title.
- Title - Specifies the title of the exported document.
- Resolution (dpi) - Specifies the resolution (in dpi) used to export a dashboard.
- Include Filters - Allows you to include master filter values to the exported document.
- Include Parameters - Allows you to include parameter values to the exported document.
Specify the required options in this dialog and click Export to export the dashboard. To reset changes to the default values, click the Reset button.
- Export to Excel
Invokes a dialog that allows end-users to export a dashboard’s data to the Excel file. The following options are available:
- Excel Format - Specifies the Excel workbook format in which the dashboard’s data is exported. You can select between XLSX and XLS.
- Include Filters - Allows you to include master filter values to the exported document.
- Include Parameters - Allows you to include parameter values to the exported document.
- Position - Specifies the position of the master filter and parameter values in the exported document. You can select between Below and Separate Sheet.
Specify the required options in this dialog and click Export to export the dashboard. To reset changes to the default values, click the Reset button.
Print or Export a Dashboard Item in the UI
To print or export a dashboard item, click the Export To button in its caption and choose the format.
- Export to PDF
- Invokes a dialog that allows end-users to export a dashboard to a PDF file with specific options.
- Export to Image
- Invokes a dialog that allows end-users to export a dashboard to an image in the specified format.
- Export to Excel
- Invokes a dialog that allows end-users to export a dashboard item’s data to the Excel workbook or CSV file.
To learn more about printing/exporting specifics of different dashboard items, see the Printing and Exporting topic for the required dashboard item.
Print or Export a Dashboard Item and a Dashboard in Code
The DashboardControl control exposes an API that allows you to customize default export options, export dashboard and dashboard items, and so on.
- ShowPrintPreview()
- Invokes the Print Preview, which shows the print preview of the dashboard.
- ShowDashboardItemPrintPreview(String)
- Invokes the Print Preview, which shows the print preview of the dashboard item.
- PdfExportOptions
- Provides access to options related to exporting a dashboard/dashboard item to PDF format.
- ImageExportOptions
- Provides access to options related to exporting a dashboard/dashboard item to an image.
- ExcelExportOptions
- Provides access to options related to exporting a dashboard item to Excel format.
- ExportToPdf
- Exports a dashboard to the specified stream in PDF format using the specified PDF-specific options.
- ExportToImage
- Exports a dashboard to the specified stream in Image format using the specified image-specific options.
- ExportToExcel
- Exports dashboard data to the specified stream in Excel format.
- ExportDashboardItemToPdf
- Exports the dashboard item to the specified stream in PDF format using the specified PDF-specific options.
- ExportDashboardItemToImage
- Exports the dashboard item to the specified stream in Image format using the specified image options.
- ExportDashboardItemToExcel
- Exports the dashboard item to the specified stream in Excel format using specified export options.
- BeforeExportDocument
- Allows you to hide specific dashboard items when printing or exporting the entire dashboard.
- CustomExport
- Occurs before you save the exported document to the PDF and Image formats and allows you to customize the exported document.
- CustomizeExportDocument
- Allows you to customize the stream containing the resulting document (such as PDF, Image, or Excel).
Non-Visual Export
You can use the non-visual DashboardExporter component to implement server-side export of a dashboard or dashboard items without referencing dashboard UI controls ( DashboardDesigner, DashboardViewer, ASPxDashboard, and so on) or DashboardConfigurator.
To integrate the DashboardExporter
into a service, register the DevExpress NuGet feed as a package source and install the DevExpress.Dashboard.Core package. See the DashboardExporter class description for details.
Custom Export
The Dashboard Control raises the DashboardControl.CustomExport event before saving the exported document to the PDF and Image formats. Use this event to obtain the printable control(s) and customize the exported document.
The following table illustrates dashboard items and their corresponding printable XRControls:
Dashboard Item | XRControl |
---|---|
ChartDashboardItem | XRChart |
ScatterChartDashboardItem | XRChart |
PieDashboardItem | XRChart |
RangeFilterDashboardItem (When CustomExportBaseEventArgs.ExportMode is SingleItem) | XRChart |
GaugeDashboardItem | XRGaugeDashboardItem |
TextBoxDashboardItem | XRTextBox |
The following example shows how to customize dashboard items in the exported document when you handle the DashboardDesigner.CustomExport / DashboardViewer.CustomExport / DashboardControl.CustomExport events. You can use the CustomExportEventArgs.GetPrintableControls method to obtain the printable controls.
using DevExpress.DashboardCommon;
using DevExpress.DashboardExport;
using DevExpress.DashboardWin;
using DevExpress.XtraCharts;
using DevExpress.XtraGauges.Core.Drawing;
using DevExpress.XtraGauges.Win.Base;
using DevExpress.XtraGauges.Win.Gauges.Circular;
using DevExpress.XtraReports.UI;
private void DashboardControl_CustomExport(object sender, CustomExportEventArgs e) {
foreach(var printControl in e.GetPrintableControls()) {
if(printControl.Value is XRGaugeDashboardItem) {
var gaugeItemName = printControl.Key;
DashboardControl control = (DashboardControl)sender;
var gaugeDashboardItem = control.Dashboard.Items[gaugeItemName] as GaugeDashboardItem;
foreach(var dashGaugeElement in gaugeDashboardItem.Gauges) {
foreach(var gaugePanel in e.GetGaugeContext(gaugeItemName).GetPrintableGauges(dashGaugeElement).Cast<XRDashboardGauge>()) {
if(gaugePanel != null) {
gaugePanel.MainSeriesLabel.ForeColor = Color.Red;
}
}
}
}
if(printControl.Value is XRChart) {
var chartItemName = printControl.Key;
DashboardControl control = (DashboardControl)sender;
var chartDashboardItem = control.Dashboard.Items[chartItemName] as ChartDashboardItem;
foreach(var pane in chartDashboardItem.Panes) {
if(pane.Series.Count > 0) {
foreach(var dashSeries in pane.Series) {
if(dashSeries != null) {
var controlSeries = e.GetChartContext(chartItemName).GetControlSeries(dashSeries);
if(controlSeries != null) {
foreach(var ser in controlSeries) {
LineSeriesView view = ser.View as LineSeriesView;
if(view != null) {
view.LineStyle.DashStyle = DashStyle.DashDot;
}
}
}
}
}
}
}
}
}
}