Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
These print options allow users to:
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.
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.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Create a new workbook
Workbook workbook;
// Get the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Get the PageSetup object of the worksheet
PageSetup pageSetup = worksheet.GetPageSetup();
// Set the print area to the range A1:T35
pageSetup.SetPrintArea(u"A1:T35");
// Save the workbook
workbook.Save(outDir + u"SetPrintArea_out.xls");
std::cout << "Print area set successfully!" << std::endl;
Aspose::Cells::Cleanup();
}
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.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Path of output excel file
U16String outputFilePath = outDir + u"SetPrintTitle_out.xls";
// Create a new workbook
Workbook workbook;
// Obtain the reference of the PageSetup of the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
PageSetup pageSetup = worksheet.GetPageSetup();
// Define column numbers A & B as title columns
pageSetup.SetPrintTitleColumns(u"$A:$B");
// Define row numbers 1 & 2 as title rows
pageSetup.SetPrintTitleRows(u"$1:$2");
// Save the workbook
workbook.Save(outputFilePath);
std::cout << "Print titles set successfully!" << std::endl;
Aspose::Cells::Cleanup();
return 0;
}
The PageSetup class also provides several other properties to set general print options as follows:
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”. |
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Create a new workbook
Workbook workbook;
// Get the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Get the PageSetup object of the worksheet
PageSetup pageSetup = worksheet.GetPageSetup();
// Set print options
pageSetup.SetPrintGridlines(true); // Allow printing gridlines
pageSetup.SetPrintHeadings(true); // Allow printing row/column headings
pageSetup.SetBlackAndWhite(true); // Allow printing in black & white mode
pageSetup.SetPrintComments(PrintCommentsType::PrintInPlace); // Print comments as displayed
pageSetup.SetPrintDraft(true); // Print with draft quality
pageSetup.SetPrintErrors(PrintErrorsType::PrintErrorsNA); // Print cell errors as N/A
// Save the workbook
U16String outputPath = outDir + u"OtherPrintOptions_out.xls";
workbook.Save(outputPath);
std::cout << "Workbook saved with print options successfully!" << std::endl;
Aspose::Cells::Cleanup();
}
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:
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. |
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Create a new workbook
Workbook workbook;
// Obtain the reference of the PageSetup of the first worksheet
PageSetup pageSetup = workbook.GetWorksheets().Get(0).GetPageSetup();
// Set the printing order of the pages to over then down
pageSetup.SetOrder(PrintOrderType::OverThenDown);
// Save the workbook
workbook.Save(outDir + u"SetPageOrder_out.xls");
std::cout << "Page order set successfully!" << std::endl;
Aspose::Cells::Cleanup();
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.