// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet1 = workbook.getWorksheets().get(0); IWorksheet worksheet2 = workbook.getWorksheets().add(); // Add the original view. workbook.getCustomViews().add("Original", true, true); worksheet1.getRange("J12").setValue(1); worksheet2.getRange("J12").setValue(2); worksheet1.getPageSetup().setPrintArea("$C$4:$J$12"); worksheet2.getPageSetup().setPaperSize(PaperSize.A4); // Add a new view which saves the current page settings of all worksheets. workbook.getCustomViews().add("PrintSetting", true, false); worksheet1.getRange("5:6").setHidden(true); worksheet2.getRange("5:6").setHidden(true); // Add a new view which saves the current hidden rows/columns, filter settings of all worksheets. workbook.getCustomViews().add("HiddenRows", false, true); // Save to an excel file workbook.save("CustomWorkbookViews.xlsx");