Skip to main content
A newer version of this page is available. .

How to: Print the Document

  • 2 minutes to read

This example demonstrates how to use a PrintableComponentLink to print a document loaded in a Workbook instance.

This example demonstrates how to invoke the Print Preview form for a Workbook instance (workbook, in this example). To do this, follow the steps below.

using DevExpress.Spreadsheet;
using DevExpress.XtraPrinting;
            // Invoke the Print Preview dialog for the workbook.
            using (PrintingSystem printingSystem = new PrintingSystem()) {
                using (PrintableComponentLink link = new PrintableComponentLink(printingSystem)) {
                    link.Component = workbook;
                    link.CreateDocument();
                    link.ShowPreviewDialog();
                }
            }

 

Note

Embeddeed charts are not printed by default.

To print a document that contains embedded charts, in addition to the above steps, add a reference to the DevExpress.XtraSpreadsheet.v17.2.dll assembly and register required services as shown in the code snippet below:


using DevExpress.XtraSpreadsheet.Services;
using DevExpress.XtraSpreadsheet.Services.Implementation;
//...
workbook.AddService(typeof(IChartControllerFactoryService), new ChartControllerFactoryService());
workbook.AddService(typeof(IChartImageService), new ChartImageService());
See Also