Apache的POI - 打印布局,在相同纸上打印多打印区域 [英] Apache poi - print layout, more than one print area in the same sheet

查看:1351
本文介绍了Apache的POI - 打印布局,在相同纸上打印多打印区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立一个复杂的报表,我需要设置打印区域的Excel文件。我必须把XLS文件在第3部分,但如果我不setPrintArea(..)新区认购老的结果是,我在打印preVIEW只有最后一页。如何设置多个打印区域吗?这是code:

I'm trying to develop a complex report, and I need to set up the print areas for the excel file. I must divide the xls file in 3 part, but if I do setPrintArea(..) the new area subscribe the old and the result is that I have in the print preview only the last page. How can I set more than one print area? This is the code:

protected void createCustomerSheet(String label) {
    createSheet(label);
    getCurrentSheet().getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE);
    getCurrentSheet().getPrintSetup().setFitHeight((short)1);
    getCurrentSheet().getPrintSetup().setFitWidth((short)1);
    getCurrentSheet().setAutobreaks(true);
    getCurrentSheet().setFitToPage(true);
}

然后我打电话3次

then I call 3 times

 wb.setPrintArea(activeSheetIndex, startColumn, endColumn, startRow, endRow);

我也试图添加破行,但它不能正常工作。

I also tried to add break rows, but it doesn't work..

任何想法?

推荐答案

Excel中只保留<一个href=\"http://www.howtogeek.com/howto/10451/print-only-selected-areas-of-a-s$p$padsheet-in-excel-2007-2010/\">print区获取A S preadsheet。所以,Apache的POI的Excel的API提供了设置一个打印区域的能力

Excel maintains only one print area for a spreadsheet. So Apache POI's Excel API provides the ability to set one print area.

这听起来像你可能试图定义报表的不同页面。如果是这样,你需要设置行和/或分栏符在您想要完成这件事每一张纸。使用以下方法,假设实例:

It sounds like you might be trying to define different pages of a report. If so, you'll need to set row and/or column breaks in each Sheet in which you want this done. Use the following methods of Sheet, assuming sheet is your Sheet instance:

sheet.setAutobreaks(false);
sheet.setRowBreak(rowIndex);
sheet.setColumnBreak(columnIndex);

您可以多次调用每个这些最后的2种方法来建立多休息。

You may call each of those last 2 methods multiple times to establish multiple breaks.

这篇关于Apache的POI - 打印布局,在相同纸上打印多打印区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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