Free Support Forum - aspose.com

Worksheet - Page Setup Options

Hi,

How can I set the Print area of my excel sheet using aspose.cell

This print area is dynamic depending on the user's data. For example if user have data for 50 rows so only that data should be printed no other extra blank sheet should be printed.

Thanks

Monisha.

Hi Monisha,

Well, you may use PageSetup.PrintArea property to specify your worksheet printing area.

E.g. (If the printing area is dynamic),

Workbook workbook = new Workbook();
int maxrow = workbook.Worksheets[0].Cells.MaxDataRow+1;
int maxcol = workbook.Worksheets[0].Cells.MaxDataColumn+1;
workbook.Worksheets[0].PageSetup.PrintArea = "A1" + ":" + CellsHelper.ColumnIndexToName(maxcol).ToString()+ CellsHelper.RowIndexToName(maxrow).ToString();
.
.
.
And if the area is static,

workbook.Worksheets[0].PageSetup.PrintArea = "A1:T50";

For further ref, please check:

http://www.aspose.com/wiki/default.aspx/Aspose.Cells/SettingPrintOptions.html

Thank you.