// Create a new workbook Workbook workbook = new Workbook(); workbook.open(this.getResourceStream("xlsx/PageSetup Demo.xlsx")); IWorksheet worksheet = workbook.getWorksheets().get(0); //Set print area & print titles worksheet.getPageSetup().setPrintArea("$D$5:$G$10"); worksheet.getPageSetup().setPrintTitleRows("$5:$10"); worksheet.getPageSetup().setPrintTitleColumns("$D:$G"); // Save to an excel file workbook.save("ConfigPrintArea.xlsx");