NPOI分页符 [英] NPOI Page Breaks

查看:1913
本文介绍了NPOI分页符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NPOI框架生成二千零三分之九十七Excel工作簿。我需要设置一个分页符每44行,从框架下载提供的示例中,code要做到这一点:

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 do this is:

sheet.SetRowBreak(INT行)

sheet.SetRowBreak(int row)

我可以确认这些设置排整数的集合,但打开文档和查看分页符preVIEW的时候,是有的,但包含整个工作表中的单个页面。

I can verify these are setting a collection of row integers but when opening the document and viewing the Page Break preview, there is but a single page that encompasses the entire worksheet.

样code以下:

for(int rowCount = 0; rowCount < MaxRows; rowCount += 44)
{
   worksheet.SetRowBreak(rowCount);
}

想法?

推荐答案

这是因为,从NPOI的默认值。它被设置为适应整个事情一页。只是这行添加到您的code和如果工作表中包含足够的行或列,你应该有一个以上的页面。

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;

但如果你想以适应您的工作表宽度一页不改变FitToPage属性,但添加像这样到code:

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

接着工作表中总是将有一个页面或更少的宽度和9999页或更少的高度。

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

这篇关于NPOI分页符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆