Printing Selection in a worksheet

Posted by: tadekunle on 22 November 2021, 10:30 am EST

  • Posted 22 November 2021, 10:30 am EST


    I would like to print a particular selection in a worksheet all in one page and I have gone through the demo posted here .
    I am trying to print the selected rows and columns all on one page while in landscape orientation, but anytime I try to set the columnEnd property to 10 or more, the excess columns are put on other pages like in the first screenshot.
    How do I ensure that no matter how many columns I intend to add to the print region, when I decide to print, all the columns (or rows) fit into one page?

    I also tried printing a worksheet in my demo app and it is showing blank pages. Below is a snippet of my code and screenshots of what I have on my spread control vs what is printing.

    rowStart = 62;
    rowEnd = -90;
    columnStart = 10;
    columnEnd = 18;

    // printInfo['rowStart'](rowStart);
    // printInfo['rowEnd'](rowEnd);
    // printInfo['columnStart'](columnStart);
    // printInfo['columnEnd'](columnEnd);



    Thank you for your help.

  • Replied 22 November 2021, 8:10 pm EST


    To fit all content on one page, you may use the fitPagesWide and fitPagesTall method of printInfo to set the max no of pages to use. You may refer to the following sample:

    Also, please note that webapp do not have access to modify the print settings of the browser, so in the print dialog you need to make sure that the page size is the same as the one specified in the printInfo(default is Letter) as well there are not any margins or padding defined in the browser print settings.

  • Replied 23 November 2021, 10:35 am EST


    I went through your code snippet and it seemed to work for the data set you had in the workbook. The first screenshot was the result i got. Is there any reason why some of the data does not show up?

    After trying it with the data you have, I added some additional columns of dummy data (see second screenshot) and tested out your snippet again but it does not seem to be printing all in one page (see third screenshot). How do i print all data/columns on one page even after adding multiple columns

  • Replied 23 November 2021, 3:56 pm EST

    In the previous sample, the paper size and orientation is set to Letter and portrait respectively which is why having any other settings in the browser print dialog could result in more pages. Please make sure that browser settings match the following when print in the previously shared sample:

    If you want to print in landscape mode on A4 paper than you need to specify those settings in the printInfo and match the same in the browser print dialog. Please refer to the following sample and the screenshot:

    API docs:
    • printInfo:
Need extra support?

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

Learn More

Forum Channels