This topic explains various printing options available in Spread for WPF. You can print a worksheet, the complete workbook, or a specified range of worksheets based on your requirements.
To perform all these printing operations, use the Print and PrintToDocument methods of the GcSpreadSheet class. Using the PrintToDocument method, you can view the printed pages in the DocumentViewer. However, if you want to print without customizing any print settings, simply pass NULL to these print methods.
Note that the following are not supported during the printing process.
To print an entire workbook, use the Print method of GcSpreadSheet class. You need to set the parameter of this method to -1 to include all the worksheets of the workbook for printing.
The following example code prints the complete workbook.
To print a worksheet, use the Print method of the GcSpreadSheet class. To print individual worksheets in a workbook, you need to specify a worksheet by its index. The default value of this method is -1, which prints the entire workbook.
The following example code shows how to print a worksheet with index 1.
To print a range of worksheets in a workbook, define the range to print by specifying the first and last worksheets in the FromPage and ToPage properties of the PrintSettings class.
The following example code shows how to print a specific range of worksheets within a workbook.
To print a specific area of a worksheet, you can specify the print region rather than printing the entire workbook. Set the PrintArea property in the PrintSettings class to specify the cell range that you want to define as the print area. You can set the range to be printed as a Reference with row/column indexes or as A1 references. However, if you set the PrintArea to Reference.Empty, it prints the complete worksheet. Note that this property applies only to the worksheets.
The following example code shows how to set the print area in the worksheet.
Print titles allow you to choose which rows and columns should appear repeatedly on each printed page. The rows' title indicates the rows that contain the cells to be repeated at the top of each page, while the columns' title specifies the columns that contain the cells to be repeated on the left side of each page.
Use PrintTitleRows and PrintTitleColumns properties of the IPageSetUp interface to select which rows and columns will appear on each printed page.
The following example code sets the rows and columns that will be printed as titles on each page.