PageSetup.setPrintArea Java problem

I’m using to create Excel sheets on a Linux platform. The workbook has 15 sheets. The first one is a summary. The rest are paired data and chart sheets with the data sheets hidden. The chart sheets contain 1-35 charts. I want the user to be able to print the workbook and have all visible sheets print correctly with no extra sheets. Initially, I was getting extra pages because of the way Excel determined the end of the print area. (It was including an extra column.) Now, I include code like this for each data/chart pair:

// set print area for chart worksheet and hide data sheet

PageSetup setup = chartSheet.getPageSetup();
setup.setPrintArea(“A1:” + colIds[maxCol] + (maxRow + 1));
logger.debug("Print area: " + setup.getPrintArea());

The debug print shows the print area I expect.

When I open the workbook in Excel on my Windows XP system, The print areas are not entirely set. If I print immediately, the areas are printed incorrectly. To print correctly, I have to go to each chart page individually and select File > Page Setup. The Sheet tab shows the print area I specified. I have to press the OK button. Note that I do not make any changes. At that time, the page area is indicated in the worksheet and it will print correctly.

Over the near future, I will be adding about 8 more chart sheets to the workbook. I really do not want the users to have to repeat this operation for that many sheets!


Hi Valerie,

Could you post your created file? It will help us to fix it.

I sent the file as a private post. (I couldn’t keep this replay private) You may reply publicly here, but I don’t want the file to be public.

Hello there support,

I have discovered that running pageSetup.setPrintArea() on linux machine provides me with an error:

Caused by: ExportException: java.lang.IllegalArgumentException: Invalid formula[0]
at com.<>.api.onlinereportingexport.OnlineReportingExport.exportOnlineReport(
… 25 more
Caused by: java.lang.IllegalArgumentException: Invalid formula[0]
at Source)
at Source)
at Source)
at Source)
at Source)
at com.aspose.cells.PageSetup.a(Unknown Source)
at com.aspose.cells.PageSetup.a(Unknown Source)
at com.aspose.cells.PageSetup.setPrintArea(Unknown Source)
at com.<>.aspose.AsposeUtils.setWorksheetPrintArea(

Any ideas?
This same code works fine on windows:
PageSetup pageSetup = ws.getPageSetup();
String rangeStart = getExcelColumnName(0) + Integer.toString(rowNumberStart);
String rangeEnd= getExcelColumnName( ws.getCells().getMaxColumn() + 1) + Integer.toString(ws.getCells().getMaxRow() + 1);
pageSetup.setPrintArea(rangeStart + “:” + rangeEnd);


Could you try our latest Aspose.Cells for Java v2.5.1.9 in which we have made lots of enhancements.

Kindly let us know if it works fine on Linux environment. If you still find the issue on Linux platform, please give us more details about the issue, also do you use some template file. You may also give us your complete sample code to reproduce the issue on your mentioned environment, we will check it soon.

Thank you.