Skip to main content
All docs
V22.2

DashboardExporter Class

Allows you to implement server export of a dashboard or dashboard items for all platforms.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v22.2.Core.dll

NuGet Packages: DevExpress.Dashboard.Core, DevExpress.Win.Dashboard.Design

Declaration

public class DashboardExporter :
    DashboardExporterBase

Remarks

The non-visual DashboardExporter component allows you to export the DevExpress BI Dashboard as a PDF, XLS, XLSX, and image (PNG, JPEG, GIF) 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.

Then, create a DashboardExporter instance and use its events to configure a dashboard and the dashboard’s data sources. Call exporter’s methods to export a dashboard or dashboard item (such as DashboardExporter.ExportToPdf or DashboardExporter.ExportDashboardItemToImage).

You can also specify a dashboard state and export options to be applied in the resulting document. For this, pass a DashboardState object and the specified export options (such as DashboardPdfExportOptions or DashboardExcelExportOptions) as parameters to the ExportTo... methods.

The following code example shows how to export a dashboard in PDF format in a console application:

View Example: BI Dashboard - Non-Visual Export Component

The DashboardExporter.ExportToPdf method exports a dashboard in a Pdf file. The following events is used to detect and display possible errors:

using System;
using System.IO;
using DevExpress.DashboardCommon;

namespace DashboardExporterApp {
    class Program {
        static void Main(string[] args) {
            if(args.Length < 1 || !Directory.Exists(args[0])) {
                Console.WriteLine("Path to the dashboard and output folders are required");
                return;
            }
            string[] dashboards = Directory.GetFiles(args[0], "*.xml");
            string outputFolder = args[1];
            DashboardExporter exporter = new DashboardExporter();
            exporter.ConnectionError += Exporter_ConnectionError;
            exporter.DataLoadingError += Exporter_DataLoadingError;
            exporter.DashboardItemDataLoadingError += Exporter_DashboardItemDataLoadingError;
            foreach(string dashboard in dashboards) {
                string outputFile = Path.Combine(outputFolder, 
                    $"{Path.GetFileNameWithoutExtension(dashboard)}.pdf");
                using FileStream stream = new FileStream(outputFile, FileMode.OpenOrCreate);
                try {
                    exporter.ExportToPdf(dashboard, stream);
                }
                catch(Exception e) {
                    Console.WriteLine($"Unable to export {dashboard}.");
                    Console.WriteLine(e.Message);
                    continue;
                }
            }
            Console.WriteLine("Done!");
        }
        static void Exporter_ConnectionError(object sender,
            DashboardExporterConnectionErrorEventArgs e) {
            Console.WriteLine(
                $"The following error occurs in {e.DataSourceName}: {e.Exception.Message}");
        }
        static void Exporter_DataLoadingError(object sender, 
            DataLoadingErrorEventArgs e) {
            foreach(DataLoadingError error in e.Errors)
                Console.WriteLine(
                    $"The following error occurs in {error.DataSourceName}: {error.Error}");
        }
        static void Exporter_DashboardItemDataLoadingError(object sender, 
            DashboardItemDataLoadingErrorEventArgs e) {
            foreach(DashboardItemDataLoadingError error in e.Errors)
                Console.WriteLine(
                    $"The following error occurs in {error.DashboardItemName}: {error.Error}");
        }
    }
}

More Examples

Non-Visual Custom Export

This example shows how to use the DashboardExporter component in a console application to export a dashboard with a custom Funnel item.

View Example: BI Dashboard - Non-Visual Custom Export

Use MailKit to Send a Dashboard as a Document in PDF

This example demonstrates how to email a dashboard with the MailKit email client library.

View Example: BI Dashboard - How to Use MailKit to Send a Dashboard as a Document in PDF

Email a Dashboard that Displays Different Data Depending on the Addressee

The following example shows how to use the DashboardExporter component in a console application to email a dashboard that displays different data depending on the addressee. The MailKit email client library is used in this example.

View Example: BI Dashboard - How to Email a Dashboard that Displays Different Data Depending on the Addressee

Inheritance

See Also