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

Printing RadSpreadsheet is easily done through the Print method which prints according to some given PrintWhatSettings instance. Here follows a code snippet showing how to print using RadSpreadsheet’s Print method:

C#

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

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.

Note that in Silverlight, there's no way to access the actual printer settings due to security limitations of the framework and the settings of the PrintDialog take precedence. In other words, to print to A3 paper (or with Landscape orientation), you will need to specify this both for RadSpreadsheet in the print preview control and for the printer in the PrintDialog.

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