Subheader and page break

In the Excel sheet that I'm creating (using Aspose.Cells for .NET), I have headers and subheaders. The subheader is just being rendered as merged row with some text. All works well, but when I print, a few of these subheaders fall at the bottom of the printed page and the content is on the next page. I'm trying to keep these together in the case that it won't fit on the page (e.g. the subheader and 3 rows must fit on the page, otherwise page break). What is the best way to accomplish something like this?

Thanks,
-Damien

Hi Damien,

Thanks for your inquiry.

Well, the printable page would be same as shown in Print Preview (File|Print Preview). I think you may try to use seomd PageSetup options before taking the print of the page(worksheet): http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/setting-page-options.html e.g.., PageSetup.FitToPagesTall and PageSetup.FitToPagesWide properties to adjust to one page.

Thank you.

I'm setting the page zoom, but I think I need to manually add the page breaks. The workbook is around 5 pages. The first 4 pages have the rows that need to be joined together. The 5th page has a hard page break, so that isn't the issue.

My table looks like this:

MAIN HEADER - Repeated on each page using PageSetup.PrintTitleRows

SUB HEADER - Simply a merged row

DATA ROWS - Varying rows of data under each Sub Header.

Both the sub header and the data rows repeat for each row that I have. Based on my page layout, I get something like this:

--- Page 1 ---
MAIN HEADER
SUB HEADER 1
DATA ROWS
SUB HEADER 2
DATA ROWS
SUBHEADER 3

--- Page 2 ---
MAIN HEADER
DATAROWS

... etc ...

In this instance I would want Sub Header 3 to be moved to the next printed page. Again, I think I will have to add a manual breaks, but I'm not sure how to do this without breaking at every subheader (not a valid solution). Can I find the height of the sheet while I'm building it and then insert the break when it gets to the size of the page?

-Damien

Hi Damien,

Could you attach you exel file here?

Our work is to the best of our abilities make Sheet2Print of Aspose.Cells to realize the features ms.excel do. I think the page break and scaling maybe meet your requirement. First you should get the satisfied result by the ms.excel Print Preview.

Thank you.