Manage Exporting Capabilities
- 7 minutes to read
The Web Dashboard allows end-users to export an entire dashboard or individual dashboard items.
Server-Side API
The ASP.NET MVC Dashboard extension’s server-side API allows you to customize the default export options, customize export documents at runtime, etc. To export an entire dashboard or individual dashboard items, use members of the WebDashboardExporter class.
API | Description |
---|---|
DashboardExtensionSettings.AllowExportDashboard | Gets or sets whether end-users can export a dashboard. |
DashboardExtensionSettings.AllowExportDashboardItems | Gets or sets whether end-users can export dashboard items. |
DashboardExtensionSettings.PdfExportOptions | Provides access to options related to exporting a dashboard/dashboard item to the PDF format. |
DashboardExtensionSettings.ImageExportOptions | Provides access to options related to exporting a dashboard/dashboard item to an image. |
DashboardExtensionSettings.ExcelExportOptions | Provides access to options related to exporting a dashboard item to the Excel format. |
DashboardConfigurator.BeforeExportDocument | Allows you to hide specific dashboard items when exporting the entire dashboard. |
DashboardConfigurator.CustomExport | Allows you to customize the exported document. |
DashboardConfigurator.CustomizeExportDocument | Allows you to customize the exported document. |
WebDashboardExporter.ExportDashboardItemToExcel | Exports the dashboard item to the specified stream in Excel format. |
WebDashboardExporter.ExportDashboardItemToImage | Exports the dashboard item to the specified stream in Image format. |
WebDashboardExporter.ExportDashboardItemToPdf | Exports the dashboard item to the specified stream in PDF format. |
WebDashboardExporter.ExportToExcel | Exports a dashboard to the specified stream in Excel format. |
WebDashboardExporter.ExportToImage | Exports a dashboard to the specified stream in Image format. |
WebDashboardExporter.ExportToPdf | Exports a dashboard to the specified stream in PDF format. |
How to: Add Custom Information to the Exported Dashboard at Runtime using the CustomExport Event
Client-Side API
You can use the MVC Dashboard extension’s client-side API for exporting to various formats, customizing export options, etc.
API | Description |
---|---|
ASPxClientDashboard.ExportToPdf | Exports a dashboard to a PDF file and writes it to the Response. |
ASPxClientDashboard.ExportToImage | Exports a dashboard to an Image file and writes it to the Response. |
ASPxClientDashboard.ExportToExcel | Exports dashboard data to the specified file in Excel format. |
ASPxClientDashboard.ExportDashboardItemToPdf | Exports a dashboard item to a PDF file and writes it to the Response. |
ASPxClientDashboard.ExportDashboardItemToImage | Exports a dashboard item to an Image file and writes it to the Response. |
ASPxClientDashboard.ExportDashboardItemToExcel | Exports a dashboard item to an Excel file and writes it to the Response. |
ASPxClientDashboard.GetPdfExportOptions | Allows you to obtain options related to exporting a dashboard/dashboard item to the PDF format. |
ASPxClientDashboard.GetImageExportOptions | Allows you to obtain options related to exporting a dashboard/dashboard item to an image. |
ASPxClientDashboard.GetExcelExportOptions | Allows you to obtain options related to exporting a dashboard/dashboard item to the Excel format. |
ASPxClientDashboard.SetPdfExportOptions | Allows you to specify options related to exporting a dashboard/dashboard item to the PDF format. |
ASPxClientDashboard.SetImageExportOptions | Allows you to specify options related to exporting a dashboard/dashboard item to an image. |
ASPxClientDashboard.SetExcelExportOptions | Allows you to specify options related to exporting a dashboard/dashboard item to the Excel format. |
ASPxClientDashboard.ShowExportDashboardDialog | Invokes the dialog that allows end-users to export the entire dashboard to the specified format. |
ASPxClientDashboard.ShowExportDashboardItemDialog | Invokes the dialog that allows end-users to export the dashboard item to the specified format. |
How to: Add Custom Information to the Exported Dashboard at Runtime using the CustomExport Event
Implement Server-Side Export
The WebDashboardExporter class allows you to implement server export for the ASP.NET MVC Dashboard extension and ASP.NET Core Dashboard control. You can specify a dashboard state and export options to be applied to the resulting document. Refer to the WebDashboardExporter class description for more information.
This example demonstrates how to export a dashboard displayed using the ASP.NET MVC Dashboard extension on the server side using the WebDashboardExporter class. The following API is used to implement this capability:
- The ASPxClientDashboard.BeforeRender event is handled to obtain the client-side DashboardControl using the ASPxClientDashboard.GetDashboardControl method.
- The AJAX request is used to send the dashboard identifier and state to the server side. On the server side, these values are received as action method parameters and passed to the WebDashboardExporter.ExportToPdf method.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/aspnet-mvc-dashboard-how-to-implement-server-side-export-t590027.
- _rootLayout.cshtml (C#)
- HomeController.cs
- DashboardExport.js (C#)
- DashboardConfig.cs
- Index.cshtml (C#)
- Global.asax.cs
- HomeController.vb
- DashboardConfig.vb
- Global.asax.vb
- Index.cshtml (VB.NET)
- _rootLayout.cshtml (VB.NET)
- DashboardExport.js (VB.NET)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Dashboard Web Application</title>
<script src="@Url.Content("~/Scripts/DashboardExport.js")" type="text/javascript"></script>
@Html.DevExpress().GetStyleSheets(
new StyleSheet { ExtensionSuite = ExtensionSuite.Dashboard }
)
@Html.DevExpress().GetScripts(
new Script { ExtensionSuite = ExtensionSuite.Dashboard }
)
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
</head>
<body>
@RenderBody()
</body>
</html>