Exporting
The Reveal SDK allows you to export both dashboards and visualizations to generate new document types or images.
Supported dashboard export formats:
- Excel
- Image
- Powerpoint
Supported visualization export formats:
- Excel
- Image
All export options can be found under the Export menu item in the RevealView
overflow menu when a dashboard is opened or a visualization is maximized
When the user clicks the Export button, they can choose one of the enabled export options.
Export to Excel
An Excel export is performed when the end-user clicks the Excel menu item from the Export overflow menu.
The Excel menu item can be shown/hidden by setting the RevealView.showExportToExcel
property.
revealView.showExportToExcel = false;
When the Excel menu item is clicked, the end-user is prompted with various options which allow them to change the title of the workbook, the title of the worksheets, which worksheets to create, and whether or not to include the visualizations.
Export to Image
There are two ways to export a dashboard or visualization to an image in the Reveal SDK:
- End-User export
- Programmatic export
End-User Image Export
An end-user image export is performed when the end-user clicks the Image menu item from the Export overflow menu.
The Image menu item can be shown/hidden by setting the RevealView.showExportImage
property.
revealView.showExportImage = false;
When the Image menu item is clicked, the end-user is prompted with a dialog which allows them to choose either to copy the image to the clipboard, edit them image using the built-in image editor, or save the image to disk as a PNG.
Custom Image Export
By default, when an end-user clicks the Export Image button in the Export Image Dialog the image will be exported and added to the browsers Downloads for the end-user to choose a location to save the image file. However, this behavior can be intercepted and custom image export logic can be used instead.
To use a custom image export, you must add an event handler to the RevealView.onImageExported
event.
revealView.onImageExported = (image) => {
};
The RevealView.onImageExported
event provides the following parameter to help you save image exports:
- image - the screenshot of the dashboard that was taken
Example: A Custom Image Export
revealView.onImageExported = (image) => {
var body = window.open("about:blank").document.body;
body.appendChild(image);
};
Programmatic Image Export
To export an image of a dashboard programmatically, without the end-user interaction, you will need to invoke the RevealView.toImage
method. Calling the RevealView.toImage
method will create a screenshot of the RevealView component as it is displayed on the screen. The RevealView.toImage
method does not prompt the user with the Export Image Dialog.
revealView.toImage( image => {
//handle image
});
Example: Programmatic Image Export
<button onclick="exportToImage()">Export to Image</button>
function exportToImage() {
revealView.toImage(image => {
console.log(image);
var body = window.open("about:blank").document.body;
body.appendChild(image);
});
}
The source code to these sample can be found on GitHub
Export to PDF
A PDF export is performed when the end-user clicks the PDF menu item from the Export overflow menu.
The PDF menu item can be shown/hidden by setting the RevealView.ShowExportToPDF
property.
revealView.showExportToPDF = false;
When the PDF menu item is clicked, the end-user is prompted with various options which allows them to change the title of the PDF document, choose which visualizations to include in the document, a title and description of each visualization, as well as branding, page orientation, and language.
Export to PowerPoint
A PowerPoint export is performed when the end-user clicks the PowerPoint menu item from the Export overflow menu.
The PowerPoint menu item can be shown/hidden by setting the RevealView.ShowExportToPowerpoint
property.
revealView.showExportToPowerPoint = false;
When the PowerPoint menu item is clicked, the end-user is prompted with various options which allows them to change the title of the PowerPoint document, choose which visualizations to include in the document, a title and description of each visualization, and branding.