Pagecount when repeatrow

Posted by: bart on 8 September 2017, 1:57 pm EST

  • Posted 8 September 2017, 1:57 pm EST


    When I calculate the pagecount with spread.GetPrintPageCount(0) , he calculates 10 pages, but when I get a preview, the pagecount is 27 pages.
    On my spread is an fixed header of 16 rows and 22 columns. After removing the repeat and get a preview, the pagecount is 10 pages.

    PrintInfo pi = new PrintInfo();

    pi.RepeatRowStart = 0;
    pi.RepeatRowEnd = 16;
    pi.RepeatColStart = 1;
    pi.RepeatColEnd =22;

    Is there an solution to calculate the correct number of pages. I've created a custom printform, where an option is to select "print all pages", the "selected range", but I want to expand the options with page 1 to page (ENDPage).





  • Replied 8 September 2017, 1:57 pm EST

    Hello Bart,

    Usind the latest build of Spread, with fpSpread1.GetPrintPageCount() I got the exact number of pages that are there in preview.I would suggest you to please take help from the sample SpreadWinDemo that you got along with Spread.I hope it will help you.





  • Replied 8 September 2017, 1:57 pm EST

    We would need to see a reproduction to have a better idea of what the exact problem is. The page count is taken directly from the pre-calculated number of pages that will be printed so it is extremely odd that the two numbers would differ. If I had to make a guess as to the cause I would probably say there could be an issue with the number of repeat columns you have. In most cases 22 columns would not fit on one printed page would may be throwing the print off. But again those numbers being different is very strange. If you have a reproduction to send us that would help us to track it down. In the interim you can also play with adjusting the number of columns that are repeating and verify that you are not repeating more than that can fit on a page.


  • Replied 8 September 2017, 1:57 pm EST

    Hi Kevin,

    I tried the following:

     private void Print(bool preview)
          this.Cursor = Cursors.WaitCursor;
          Console.WriteLine("1: " + _spread.GetPrintPageCount(0));
          _printInfo.ShowPrintDialog = false;
          _printInfo.Preview = preview;
          _sheet.PrintInfo = _printInfo;
          this.Cursor = Cursors.Default;
          Console.WriteLine("2: " + _spread.GetPrintPageCount(0));

    The first (1:) GetPrintPageCount returns 1 page, after showing the preview (where the correct number of pages are printed in the header), the second (2:) GetPrintPageCount returns the correct number of pages.
    Is it possible to get or force the spread to calculate the correct number of pages, before showing the preview?



  • Replied 8 September 2017, 1:57 pm EST

    I think the problem is probably more that you are modifying the PrintInfo structure after you call GetPrintPageCount the first time. So the 2 calls to GetPrintPageCount are different. I don't know what else you ahve set into your _printInfo object but for instance if you had set the Orientation to Landscape then on the first call to GetPrintPageCount it is calculating the pages based on a Portrait print out and on the second call it would calculating the pages based on a Landscape print out. I would suggest moving all the code involved in setting the _sheet.PrintInfo to prior to the first call to GetPrintPageCount.
  • Replied 8 September 2017, 1:57 pm EST


    Problem solved. Just before the pagecount, I set the _printinfo object to the printinfo object of the sheet.



Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels