Vargan Vargan - 1 year ago 145
Java Question

Apache poi - print layout, more than one print area in the same sheet

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) {

then I call 3 times

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

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

Any ideas?

Answer Source

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:


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download