We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Is there a way to Set The Print Area

Is there a way using ASPOSE.Excel to set the print area for cells? I’d like to set the print area for example from 3,2, 102, 101?

Dear Steve,

You can set the print area in a designer file. Aspose.Excel can read the information and write it to the result file.

When the result file is opened, the print area is not shown. Press the “Print Preview” button, you can see the print area.

We recommend you to use PageSetup.PrintArea for setting the print area as shown in the following sample code:

// Instantiating a Workbook object
Workbook workbook = new Workbook();
workbook.Worksheets.Add("new sheet");
workbook.Worksheets.Add("second sheet");
Worksheet sheet1 = workbook.Worksheets[0];
sheet1.Cells[0, 0].Value = 1;
sheet1.Cells[0, 1].Value = 2;
sheet1.Cells[0, 2].Value = 3;
sheet1.Cells[1, 0].Value = 4;
sheet1.Cells[1, 1].Value = 5;
Worksheet sheet2 = workbook.Worksheets[1];
sheet2.Cells[0, 0].Value = 2.1;
sheet2.Cells[0, 4].Value = 2.2;
sheet2.Cells[0, 5].Value = 2.3;
sheet2.Cells[1, 4].Value = 2.4;
sheet2.Cells[1, 5].Value = 2.5;
// Accessing the first worksheet in the Workbook file
Worksheet sheet = workbook.Worksheets[0];
// Obtaining the reference of the PageSetup of the worksheet
PageSetup pageSetup = sheet.PageSetup;
// Specifying the cells range (from A1 cell to F20 cell) of the print area
pageSetup.PrintArea = "A1:F20";

For more details have a look at the following article:
Set Print Area

Download the latest version of Aspose.Cells for .NET from the following link:
Aspose.Cells for .NET (Latest Version)

You can download the latest demos here.