Edit this page

Printing

Printing in RadSpreadsheet allows you to prepare and display spreadsheet data the most suitable way depending on your needs. Using different printing options such as defining the print page, the scale factor or whether to print gridlines you may customize the way to present your data. Additionally Print Area and Page Breaks allows to print only what you need to print and separate big documents on pages just the way you want your data to be separated. Together with printing on a real printer, RadSpreadsheet’s printing gives you the opportunity to export your spreadsheet data in different file formats with the help of virtual printers.

This article aims to present the Printing API of RadSpreadsheet and demonstrate how to specify what and how to print the document. It contains the following subsections:

How to print RadSpreadsheet?

RadSpreadsheet provides you with variety of options for organizing and preparing the document’s data for printing.

Using the PrintWhatSettings class you may specify:

  • ExportWhat option – Enumeration specifying whether to print the Active Sheet, the Entire Workbook or the current Selection.

  • IgnorePrintArea option – Boolean value indicating whether or not to ignore print area when printing worksheets. Rad Spreadsheet UI Printing 01

Depending on whether you want to show a PrintDialog before printing you may use some of the following RadSpreadsheet’s print method overloads:

  • Print(PrintWhatSettings printWhatSettings, string printDescription = null) – prints depending on specified PrintWhatSettings instance, showing a PrintDialog, so that the user can choose a printer and set some printer specific options from the dialog.

  • Print(PrintWhatSettings printWhatSettings, PrintDialog printDialog, string printDescription = null) – prints depending on specified PrintWhatSettings instance. This overload prints silently (without showing the PrintDialog) by using an already initialized PrintDialog instance.

The following code snippet demonstrate the use of the above described Print method overloads:

C#

            PrintWhatSettings printWhatSettings = new PrintWhatSettings(ExportWhat.ActiveSheet, false);

            // Prints showing the print dialog.
            this.radSpreadsheet.Print(printWhatSettings);

            // Prints silently to the default printer without showing the print dialog.
            this.radSpreadsheet.Print(printWhatSettings, new PrintDialog());

Worksheet page setup

When you need to set different print option such as page size, page orientation or when you want to print the spreadsheet grid lines you may set this options using the worksheet's page setup. For more detailed information you may follow this link to WorksheetPageSetup documentation article.

You can apply headers and footers to the printed document. For more details on how to achieve this, refer to the Headers and Footers topic.

In order to preview the pages before printing you may use the PrintPreviewControl class and set its RadSpreadsheet property to the RadSpreadsheet instance that you want to be previewed. This control will provide ready to use functionality for previewing print pages and setting different print options.

The following code snippet shows how to integrate the print preview with RadRibbonView's backstage.

XAML

        <telerik:RadRibbonBackstageItem Header="Print" IsDefault="false">
            <spreadsheetControls:PrintPreviewControl RadSpreadsheet="{Binding Path=RadSpreadsheet, Mode=OneTime}" />
        </telerik:RadRibbonBackstageItem>

Rad Spreadsheet UI Printing 08

See Also