Hi,
Thanks for the kind words. I do agree using all the functionality in FlexCel can be difficult, but I don't think this is because we have "conceptual" documentation (as we also have "how to" documentation, in particular there are 2 demos in how to use intelligent page breaks, and also "reference" documentation, as you will see when pressing F1 on the API methods.
In my personal opinion the real problem is that Excel is a very complex thing with lots of possibilities, and any API that exposes all the complexity will end up being complex. It happens also with the OLE Automation, but you are less likely to note it because: 1) You have the macro recorder that will tell you what code you need. and 2) There are millions of webpages explaining everything just a google away. In our case, we can't do much about 2), but we doprovide an APIMate tool to compensate the fact that you can't use a macro recorder, and well, in the rest, we try to answer all questions the best we can.
In the particular case of intelligent page breaks, it is even more complex, because this isn't a feature in Excel itself. It is an unique feature we do completely on our own, to "fake" widow/orphan control in an application (Excel) that doesn't support them.
so, how do we implement ipb's if Excel doesn't support them? We have a 2 stage process. First stage, you mark all the rows you want to keep together (this is done with the KeepRows ranges). Second stage, at the end of the report, we calculate where all page breaks would naturally end, and if they end up breaking some KeepRows range, we will insert a hard page break before. (algorithm is actually quite more complex than that, but this is the idea).
So, to answer the last question, yes, you need a KeepRows range for the first stage (mark the rows we want to keep together) and a <#auto page breaks> tag in every sheet to trigger the second stage (insert hard breaks where needed to keep the rows marked together). The API works similarly, you need to call 2 different method, one for marking and the other for adding the actual page breaks, and actually this is a case where the API was modeled after the reports and not the contrary. But you can't really mix API and reports in the same thing, or you will end up calling AutoPageBreaks() twice, once yourself, and the other by the report. The first AutoPageBreaks will add the hard page breaks, and the second won't do anything.
About the actual problem you are having, it is hard to see form a screen shot, and normally Ipbs aren't too complex, but there is indeed an issue that can cause unexpected results:
FlexCel is "printer independent" in that it prints the same everywhere (it uses GDI+ for printing). Excel uses GDI, and it can print differently(and show a different print preview) depending in the printer you have. It might happen in a particular printer that from FlexCel POV row 36 will fit in the page (so it doesn't add a hard page break at row 34), but when you print-preview it in Excel with your printer, the printer has bigger "hard margins" (the places of the paper the printer uses to grab the page, in which it can't print and which actually make the page smaller). So for Excel row 36 doesn't fit, and it adds a new page break just for it.
To verify this isn't the case, you should try to preview the file in FlexCel itself, or export it to pdf from FlexCel. If the page breaks are ok there, then you need to add some "safety margins" to the page breaks to make sure no matter the printer they will show fine in Excel.
You do this by changing the parameters in the <#auto page breaks> tag. From the docs:
"Calling this tag without parameters is equivalent to calling <#auto page breaks(20;95)>"
You might need to make that default "95" smaller. (If the problem is this, that is, FlexCel printing works ok, but Excel doesn't)
If this isn't the problem, I can't see much more that could be wrong in your file, so, would it be possible for you to mail me a template and the result you get to take a closer look?
Regards,
Adrian.
Adrian Gallero2011-08-05 19:18:28