NPOI Page Breaks

前端 未结 2 1610
一生所求
一生所求 2021-01-27 07:38

I am using the NPOI framework to generate a 97/2003 Excel workbook. I need to set a page break every 44 rows and from the example provided in the framework download, the code to

2条回答
  •  情书的邮戳
    2021-01-27 08:07

    This is because of the default values from NPOI. It is set to fit the whole thing to one page. Just add this line to your code and you should have more than one page if the worksheet contains enough rows or columns.

    worksheet.FitToPage = false;
    

    But if you want to fit your worksheets width to one page don't change the FitToPage property, but add something like this to your code:

    worksheet.PrintSetup.FitHeight = 9999;
    // worksheet.PrintSetup.FitWidth = 1; // this is the default value
    

    Then your worksheet always will have the width of one page or less and the height of 9999 pages or less.

提交回复
热议问题