Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]Controls and Libraries
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Scheduler (new)
  [Collapse]Spreadsheet
    Product Structure
   [Expand]Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
   [Expand]Formulas
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
   [Expand]Pivot Table Overview
   [Expand]Charting
    Printing
    Protection
    Find and Replace
   [Expand]Visual Elements
    Services
    Themes and Templates
   [Expand]Examples
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Printing

The SpreadsheetControl provides two basic approaches to printing: printing from code using the appropriate API methods and properties, or via the spreadsheet Ribbon UI. Refer to the Lesson 1 - Create a Simple Spreadsheet topic for details on how to provide a Ribbon UI for the SpreadsheetControl.

Note

The WPF Spreadsheet uses the DXPrinting Library to print its contents or save it as a PDF or graphic file. Use the SpreadsheetControl.IsPrintingAvailable property to check whether printing is possible.

The document includes the following sections:

Expanded Preview a Workbook before Printing

  • Via the Ribbon UI

    Select the File tab and click the Print Preview button in the Common group. This invokes the Print Preview form which allows you to preview your workbook.

    At the bottom of the Preview window, you can see the number of pages and the current page's number. Note that blank worksheets are not displayed or printed. You can also print the current workbook via the Preview window by clicking the Print... button in the Print group.

  • In code

    Use the SpreadsheetControl.ShowRibbonPrintPreview or SpreadsheetControl.ShowPrintPreview method to invoke the Preview window programmatically, depending on the type of Print Preview form you wish to display - with a Ribbon or Bar UI.

Expanded Print a Workbook using the Print Dialog

  • Via the Ribbon UI

    Click the Print button in the Common group, or press CTRL+P to print a document and set print options.

    In the invoked Print dialog box, specify the required settings such as printer name, the number of copies, the page range and click Print.

  • In code

    Call the SpreadsheetControl.ShowPrintDialog method to invoke the Print dialog box programmatically.

Expanded Print a Workbook with Default Settings

  • Via the Ribbon UI

    Click the Quick Print button in the Common group to send a workbook to the default printer without setting print options.

  • In code

    Use the SpreadsheetControl.Print method to print a workbook programmatically, as shown in the example below.

Expanded Set a Print Area

  • Via the Ribbon UI

    You can define a print area to print a specific part of the worksheet. Select the cells you wish to print, and then on the Page Layout tab, in the Page Setup group, click the Print Area button. In the button's drop-down list, click Set Print Area.

    When you specify the print area, the cell range that it comprises gets a thin dashed outline and the _xlnm.Print_Area name is added to the defined names contained in the workbook.

    Extend the existing print area by selecting the cell range you wish to add to the print area, and clicking Print Area | Add to Print Area in the Page Setup group. Note that if the print area consists of non-adjacent cell ranges, they are each printed on a separate page.

    To print the entire worksheet, remove the print area by clicking Print Area | Clear Print Area.

  • In code

    Use the Worksheet.SetPrintRange method to define a print area programmatically, and the Worksheet.AddPrintRange method to add cells to the existing print area. To remove the print area, call the Worksheet.ClearPrintRange method.

    You can also display or hide the dashed border around the print area by utilizing the SpreadsheetViewOptions.ShowPrintArea property.

Expanded Print Titles

  • Via the Ribbon UI

    You can print row or column headings on every page to help improve readability. To do this, on the Page Layout tab, in the Page Setup group, click Print Titles to invoke the Page Setup dialog.

    In the Rows to repeat at top and Columns to repeat at left boxes, enter references to the title rows and/or columns you wish to repeat or select them directly in the worksheet by clicking the Collapse Dialog button .

  • In code

    Use the corresponding members of the WorksheetPrintTitleOptions object to print titles on every page programmatically. Refer to the How to: Print Titles on a Worksheet example for details.

Expanded Export to PDF

Expanded Specify Print Options

  • Via the Ribbon UI

    Before printing a workbook, an end-user can specify print settings for individual worksheets using the SpreadsheetControl's Page Setup ribbon page group. Use this group's buttons to specify page margins, document orientation, and paper size. Invoke the Page Setup dialog by clicking the Page Setup dialog box launcher to set more specific printout settings (such as print scaling, page order, header and footer options, etc.).

  • In code

    Use properties of the WorksheetView object to specify print options. WorksheetView enables you to specify general page options such as orientation, margins, and paper size settings. Use the WorksheetPrintOptions object's properties to define more print-specific options. Refer to the Printing section for examples.

Expanded Print Suppression

You can prevent worksheets from printing by handling the SpreadsheetControl.BeforePrintSheet event, which occurs before a workbook is printed. Use the Index or Name properties of the event parameter to get a worksheet to be printed, and set the Cancel property to true to cancel printing.

The example below demonstrates how to print the active worksheet only.

Expanded End-User Restrictions

The SpreadsheetControl allows you to prevent an end-user from printing a workbook. To do this, access the SpreadsheetBehaviorOptions object using the SpreadsheetControlOptions.Behavior property. This object enables you to apply restrictions on different operations in the SpreadsheetControl. Set the SpreadsheetBehaviorOptions.Print property to DocumentCapability.Disabled or DocumentCapability.Hidden to disable or hide the printing commands in the Ribbon UI.

The Quick Print, Print and Print Preview commands are disabled in the Common group as a result of executing this code.

Expanded See Also

How would you rate this topic?​​​​​​​