Free Support Forum -

Problem with Fit to Pages and Page Breaks

Hello -

I am having trouble setting page breaks when I also use the fit to page (both tall and wide) methods. For example, here is the code I’m using:

<—BEGIN CODE SNIPPET--------------------------->

oSheet.PageSetup.PrintTitleColumns = “$A:$B”

oSheet.PageSetup.PrintArea = “A1:” & _LastCell

oSheet.PageSetup.FitToPagesWide = 3 '(_ReportCriteria._EndYear - _ReportCriteria._StartYear) + 1

oSheet.PageSetup.FitToPagesTall = 3 ’ _dsReportData.Tables(DATA_TABLE_MEASURES).Rows.Count

For Each Cell As String In _PageBreak




oSheet.PageSetup.Order = PrintOrderType.OverThenDown

<—END CODE SNIPPET--------------------------->

When I use the fit to page commands, the page breaks do not get set at all. If I leave out the fit to page commands, the page breaks appear, but Excel formats the additional page breaks in between my page breaks. Any help?

I just came across an article on your website that says if the fit to page commands are used, page breaks are ignored. Do you have any plans to add this functionality to Aspose.Excel? MS Excel can handle fit to page and page breaks.

Do you have any suggestions in the meantime how I can accomplish adding page breaks and also making sure I only have a set # of pages printed?



No. MS Excel cannot handle fit to page and page breaks at same time. You can set fit to pages option and MS Excel will automatically set page breaks and will ignore your manually set page breaks. You can verify it in MS Excel.