Setting Print Options with Golang via C++

Setting Print Options

These print options allow users to:

  • Select a specific print area on a worksheet.
  • Print titles.
  • Print gridlines.
  • Print row/column headings.
  • Print in draft quality.
  • Print comments.
  • Print cell errors.
  • Define page ordering.

Aspose.Cells supports all the print options offered by Microsoft Excel, and developers can easily configure these options for worksheets using the properties offered by the PageSetup class. How these properties are used is discussed below in more detail.

Set Print Area

By default, the print area incorporates all areas of the worksheet that contain data. Developers can establish a specific print area of the worksheet.

To select a specific print area, use the PageSetup class’s GetPrintArea() method. Assign a cell range that defines the print area to this property.

Set Print Titles

Aspose.Cells allows you to designate row and column headers to repeat on all pages of a printed worksheet. To do so, use the PageSetup class’s GetPrintTitleColumns() and GetPrintTitleRows() properties.

The rows or columns that will be repeated are defined by passing their row or column numbers. For example, rows are defined as $1:$2 and columns are defined as $A:$B.

Set Other Print Options

The PageSetup class also provides several other properties to set general print options as follows:

  • GetPrintGridlines(): a Boolean property that defines whether to print gridlines or not.
  • GetPrintHeadings(): a Boolean property that defines whether to print row and column headings or not.
  • GetBlackAndWhite(): a Boolean property that defines whether to print the worksheet in black and white mode or not.
  • GetPrintComments(): defines whether to print comments on the worksheet or at the end of the worksheet.
  • GetPrintDraft(): a Boolean property that defines whether to print the sheet without graphics.
  • GetPrintErrors(): defines whether to print cell errors as displayed, blank, dash, or N/A.

To set the GetPrintComments() and GetPrintErrors() properties, Aspose.Cells also provides two enumerations, PrintCommentsType and PrintErrorsType that contain pre‑defined values to be assigned to those properties respectively.

The pre‑defined values in the PrintCommentsType enumeration are listed below with their descriptions.

Print Comments Types Description
PrintInPlace Specifies to print comments as displayed on the worksheet.
PrintNoComments Specifies not to print comments.
PrintSheetEnd Specifies to print comments at the end of the worksheet.

The pre‑defined values of PrintErrorsType enumeration are listed below with their descriptions.

Print Errors Types Description
PrintErrorsBlank Specifies not to print errors.
PrintErrorsDash Specifies to print errors as “–”.
PrintErrorsDisplayed Specifies to print errors as displayed.
PrintErrorsNA Specifies to print errors as “#N/A”.

Set Page Order

The PageSetup class provides the GetOrder() property, which is used to specify the order of multiple pages of your worksheet to be printed. There are two possible orders:

  • Down then over: prints all the pages downward before printing any pages to the right.
  • Over then down: prints pages left to right before printing the pages below.

Aspose.Cells provides an enumeration, PrintOrderType that contains all pre‑defined order types.

The pre‑defined values of the PrintOrderType enumeration are listed below.

Print Order Types Description
DownThenOver Represents printing order as down then over.
OverThenDown Represents printing order as over then down.