我正在尝试开发一份复杂的报告,并且需要为 Excel 文件设置打印区域。我必须将 xls 文件分成 3 部分,但如果我执行 setPrintArea(..) ,新区域会订阅旧区域,结果是我在打印预览中只有最后一页。如何设置多个打印区域?这是代码:
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次电话
wb.setPrintArea(activeSheetIndex, startColumn, endColumn, startRow, endRow);
我也尝试添加断行,但它不起作用..
有任何想法吗?
Excel只维护一个打印区域 http://www.howtogeek.com/howto/10451/print-only-selected-areas-of-a-spreadsheet-in-excel-2007-2010/用于电子表格。因此 Apache POI 的 Excel API 提供了以下功能:设置一个打印区域 http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Workbook.html.
听起来您可能正在尝试定义报告的不同页面。如果是这样,您需要在要完成此操作的每个工作表中设置行和/或列分隔符。使用以下方法Sheet http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Sheet.html, 假设sheet
是你的Sheet
实例:
sheet.setAutobreaks(false);
sheet.setRowBreak(rowIndex);
sheet.setColumnBreak(columnIndex);
您可以多次调用最后两个方法中的每一个来建立多个中断。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)