I am trying to create dynamic page breaks, but I am struggling to understand how and what to do to get it right (I am no expert on Excel either).
Attached is a zip file with three files in it.
The template file is the base where I work from. This is the definition.
Note that there are a couple of lines at the top which I’ve set to print on every page as a header.
From this file, I create the actual excel ‘report data’ file and hence contains multiples of the template. I do this by means of copying the cells / rows from the template to the new file in the correct place.
Note that line(s) are then hidden where irrelevant data is.
I have a sort of manual counter process where I calculate where a page break should be. A page break should happen if the visible lines of the ‘template’ will go off the page. The count of lines per page I’ve set to 210 (and this could be wrong as I might not understand the way to calculate it correctly)
So then I insert page breaks where on the blue separator line with the code below :
workSheet.VerticalPageBreaks.Add(“A” + pb.Row); // where pb.Row is the row calculated (first one is 209)
Once the whole process is done, the excel file is converted to pdf - the third file attached, with the following piece of code :
ReportAspose.Settings.CreateCalcChain = false; //Calculate the workbook formulas ReportAspose.CalculateFormula(); ReportAspose.Save(_AsposeExcel, SaveFormat.Auto);
I have the following issues :
The page breaks that I have inserted don’t seem to have any effect at all. Am I supposed to use VerticalPageBreaks or HorizontalPageBreaks ? (Note that the paper is set as A0 Landscape)
When I preview the excel file, the lines on top which should be on every page, is not there, yet on the PDF they are there. Is this normal / expected behavior ?
ExcelPageBreaks.zip (628.1 KB)
Any help would be appreciated.