Back to Devexpress

Printing and Exporting

windowsforms-118363-controls-and-libraries-treemap-end-user-interaction-printing-and-exporting.md

latest6.0 KB
Original Source

Printing and Exporting

  • Oct 10, 2022
  • 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.v25.2.Core assembly to be capable of completing the following tasks.

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.

csharp
private void printButton_OnClick(object sender, EventArgs e) {
    treeMap.Print();
}
vb
Private Sub printButton_OnClick(sender As Object, e As EventArgs)
    treeMap.Print()
End Sub

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.

csharp
private void printButton_OnClick(object sender, EventArgs e) {
    treeMap.ShowPrintDialog();
}
vb
Private Sub printButton_OnClick(sender As Object, e As EventArgs)
    treeMap.ShowPrintDialog()
End Sub

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.

MethodDescription
HierarchicalChartControlBase.ShowRibbonPrintPreviewCreates a document to be printed and displays the Print Preview.
HierarchicalChartControlBase.ShowPrintPreviewCreates 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.

csharp
private void printButton_OnClick(object sender, EventArgs e) {
    treeMap.ShowRibbonPrintPreview();
}
vb
Private Sub printButton_OnClick(sender As Object, e As EventArgs)
    treeMap.ShowRibbonPrintPreview()
End Sub

To immediately print a treemap, select the Quick Print item in the Preview.

  1. The Print Preview

  1. The Ribbon Print Preview

To show the standard system dialog before printing, select the Print item.

  1. The Print Preview

  1. The Ribbon Print Preview

Select a format from the Export To item’s drop-down list to export a treemap.

  1. The Print Preview

  1. The Ribbon Print Preview

Export a Treemap from Code

The TreeMap control supports the capability to export a treemap to numerous file formats.

MethodDescription
HierarchicalChartControlBase.ExportToImageExports a treemap to an image file.
HierarchicalChartControlBase.ExportToMhtExports a treemap to an MHT file.
HierarchicalChartControlBase.ExportToPdfExports a treemap to a PDF file.
HierarchicalChartControlBase.ExportToRtfExports a treemap to an RTF file.
HierarchicalChartControlBase.ExportToXlsExports a treemap to an XLS file.
HierarchicalChartControlBase.ExportToXlsxExports a treemap to an XLSX file.
HierarchicalChartControlBase.ExportToDocxExports a treemap to a DOCX file.
HierarchicalChartControlBase.ExportToHtmlExports a treemap to an HTML file.

The code below shows how to export a treemap to a PNG image.

csharp
private void printButton_OnClick(object sender, EventArgs e) {
    treeMap.ExportToImage("D:\\treemap.png", ImageFormat.Png);
}
vb
Private Sub printButton_OnClick(sender As Object, e As EventArgs)
    treeMap.ExportToImage("D:\treemap.png", ImageFormat.Png)
End Sub

See Also

Document Viewer