Printing and Exporting
- 3 minutes to read
The TreeMap control allows you to print a treemap and export it to multiple file formats.
Make sure that your project references the DevExpress.Printing.v24.2.Core assembly to be capable of completing the following tasks.
- Immediately Print a Treemap
- Print a Treemap Using the Standard Print Dialog
- Invoke the Print Preview Dialog to Print/Export a Treemap
- Export a Treemap from Code
Immediately Print a Treemap
To print a treemap by means of the system default printer without invoking any print dialogs, call the HierarchicalChartControlBase.Print method.
Print a Treemap Using the Standard Print Dialog
The system print dialog makes it possible to configure common print settings before printing. For instance, you can set the number of printed copies.
To show the system print dialog, use the HierarchicalChartControlBase.ShowPrintDialog method.
private void printButton_OnClick(object sender, EventArgs e) {
treeMap.ShowPrintDialog();
}
Invoke the Print Preview Dialog to Print/Export a Treemap
A treemap can be printed/exported with the Print Preview dialog. To invoke this dialog, use one of the following methods.
Method | Description |
---|---|
HierarchicalChartControlBase.ShowRibbonPrintPreview | Creates a document to be printed and displays the Print Preview. |
HierarchicalChartControlBase.ShowPrintPreview | Creates a document to be printed and displays the Print Preview with the Ribbon. |
The code below demonstrates how to invoke the Print Preview with the Ribbon.
private void printButton_OnClick(object sender, EventArgs e) {
treeMap.ShowRibbonPrintPreview();
}
To immediately print a treemap, select the Quick Print item in the Preview.
To show the standard system dialog before printing, select the Print item.
Select a format from the Export To item’s drop-down list to export a treemap.
Export a Treemap from Code
The TreeMap control supports the capability to export a treemap to numerous file formats.
Method | Description |
---|---|
HierarchicalChartControlBase.ExportToImage | Exports a treemap to an image file. |
HierarchicalChartControlBase.ExportToMht | Exports a treemap to an MHT file. |
HierarchicalChartControlBase.ExportToPdf | Exports a treemap to a PDF file. |
HierarchicalChartControlBase.ExportToRtf | Exports a treemap to an RTF file. |
HierarchicalChartControlBase.ExportToXls | Exports a treemap to an XLS file. |
HierarchicalChartControlBase.ExportToXlsx | Exports a treemap to an XLSX file. |
HierarchicalChartControlBase.ExportToDocx | Exports a treemap to a DOCX file. |
HierarchicalChartControlBase.ExportToHtml | Exports a treemap to an HTML file. |
The code below shows how to export a treemap to a PNG image.
private void printButton_OnClick(object sender, EventArgs e) {
treeMap.ExportToImage("D:\\treemap.png", ImageFormat.Png);
}