Printing

Printing in RadSpreadsheet allows you to prepare and display spreadsheet data in 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 can 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 presents the Printing functionality of RadSpreadsheet and demonstrates 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 can specify:

  • ExportWhat: An enumeration specifying whether to print the Active Sheet, the Entire Workbook or the current Selection.

  • IgnorePrintArea: Boolean value indicating whether or not to ignore print area when printing worksheets.

Figure 1: Choose what you would like to print

Print what settings in RadSpreadsheet

Printing RadSpreadsheet is easily done programmatically through the Print() method, which prints according to some given PrintWhatSettings instance.

Example 1: Print RadSpreadsheet programmatically

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 can set this options using the worksheet's page setup. For more detailed information you can check the WorksheetPageSetup topic.

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.

Scaling

If your worksheet contains a lot of data, you can use the scaling options provided by RadSpreadsheet to reduce the size of the worksheet so it can better fit on the printed page. There are several options to help you in achieving this:

  • No Scaling: This is the default value. The sheet is printed at its actual size.
  • Fit Sheet on One page: Shrinks the data so that it is printed on a single page.
  • Fit All Columns on One page: Shrinks the data so that it is printed on a single page wide.
  • Fit All Rows on One page: Shrinks the data so that it is printed on a single page height.
  • Custom Scaling options: The custom options enable you to set a scale factor according to your preferences or specify a particular number of pages the worksheet should be printed on.

All the scaling options are available in the Print Preview as well as in the Page Setup dialog. If you would like to set them programmatically, you can do so through the WorksheetPageSetup.

Figure 2: Scaling options

Scaling options in RadSpreadsheet

In order to preview the pages before printing, you can use the PrintPreviewControl class and set its RadSpreadsheet property to the RadSpreadsheet instance that you want to be previewed. This control will provide a 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.

Example 2: Integrate the print preview with RadRibbonView's backstage

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

Figure 3: Print preview

Print preview in Radspreadsheet

See Also

In this article
Not finding the help you need? Improve this article