List of usage examples for org.apache.poi.hssf.usermodel HSSFPrintSetup setPageStart
public void setPageStart(short start)
From source file:net.sf.jasperreports.engine.export.JRXlsExporter.java
License:Open Source License
protected void createSheet(CutsInfo xCuts, SheetInfo sheetInfo) { sheet = workbook.createSheet(sheetInfo.sheetName); patriarch = sheet.createDrawingPatriarch(); HSSFPrintSetup printSetup = sheet.getPrintSetup(); printSetup.setLandscape(jasperPrint.getOrientationValue() == OrientationEnum.LANDSCAPE); short paperSize = getSuitablePaperSize(jasperPrint); if (paperSize != -1) { printSetup.setPaperSize(paperSize); }/*from www . ja v a2 s . c o m*/ XlsReportConfiguration configuration = getCurrentItemConfiguration(); String password = configuration.getPassword(); if (password != null) { sheet.protectSheet(password); } boolean isIgnorePageMargins = configuration.isIgnorePageMargins(); if (jasperPrint.getLeftMargin() != null) { sheet.setMargin((short) 0, LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getLeftMargin())); } if (jasperPrint.getRightMargin() != null) { sheet.setMargin((short) 1, LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getRightMargin())); } if (jasperPrint.getTopMargin() != null) { sheet.setMargin((short) 2, LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getTopMargin())); } if (jasperPrint.getBottomMargin() != null) { sheet.setMargin((short) 3, LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getBottomMargin())); } Integer fitWidth = configuration.getFitWidth(); if (!isValidScale(sheetInfo.sheetPageScale) && fitWidth != null) { printSetup.setFitWidth(fitWidth.shortValue()); sheet.setAutobreaks(true); } Integer fitHeight = configuration.getFitHeight(); if (!isValidScale(sheetInfo.sheetPageScale) && fitHeight != null) { printSetup.setFitHeight(fitHeight.shortValue()); sheet.setAutobreaks(true); } String sheetHeaderLeft = configuration.getSheetHeaderLeft(); if (sheetHeaderLeft != null) { sheet.getHeader().setLeft(sheetHeaderLeft); } String sheetHeaderCenter = configuration.getSheetHeaderCenter(); if (sheetHeaderCenter != null) { sheet.getHeader().setCenter(sheetHeaderCenter); } String sheetHeaderRight = configuration.getSheetHeaderRight(); if (sheetHeaderRight != null) { sheet.getHeader().setRight(sheetHeaderRight); } String sheetFooterLeft = configuration.getSheetFooterLeft(); if (sheetFooterLeft != null) { sheet.getFooter().setLeft(sheetFooterLeft); } String sheetFooterCenter = configuration.getSheetFooterCenter(); if (sheetFooterCenter != null) { sheet.getFooter().setCenter(sheetFooterCenter); } String sheetFooterRight = configuration.getSheetFooterRight(); if (sheetFooterRight != null) { sheet.getFooter().setRight(sheetFooterRight); } RunDirectionEnum sheetDirection = configuration.getSheetDirection(); if (sheetDirection != null) { printSetup.setLeftToRight(sheetDirection == RunDirectionEnum.LTR); sheet.setRightToLeft(sheetDirection == RunDirectionEnum.RTL); } if (sheetInfo.sheetFirstPageNumber != null && sheetInfo.sheetFirstPageNumber > 0) { printSetup.setPageStart((short) sheetInfo.sheetFirstPageNumber.intValue()); printSetup.setUsePage(true); firstPageNotSet = false; } else { Integer documentFirstPageNumber = configuration.getFirstPageNumber(); if (documentFirstPageNumber != null && documentFirstPageNumber > 0 && firstPageNotSet) { printSetup.setPageStart((short) documentFirstPageNumber.intValue()); printSetup.setUsePage(true); firstPageNotSet = false; } } if (!firstPageNotSet && (sheet.getFooter().getCenter() == null || sheet.getFooter().getCenter().length() == 0)) { sheet.getFooter().setCenter("Page " + HeaderFooter.page()); } boolean showGridlines = true; if (sheetInfo.sheetShowGridlines == null) { Boolean documentShowGridlines = configuration.isShowGridLines(); if (documentShowGridlines != null) { showGridlines = documentShowGridlines; } } else { showGridlines = sheetInfo.sheetShowGridlines; } sheet.setDisplayGridlines(showGridlines); maxRowFreezeIndex = 0; maxColumnFreezeIndex = 0; onePagePerSheetMap.put(sheetIndex, configuration.isOnePagePerSheet()); sheetsBeforeCurrentReportMap.put(sheetIndex, sheetsBeforeCurrentReport); }
From source file:net.sf.jasperreports.engine.export.JRXlsMetadataExporter.java
License:Open Source License
protected void createSheet(SheetInfo sheetInfo) { sheet = workbook.createSheet(sheetInfo.sheetName); patriarch = sheet.createDrawingPatriarch(); HSSFPrintSetup printSetup = sheet.getPrintSetup(); printSetup.setLandscape(jasperPrint.getOrientationValue() == OrientationEnum.LANDSCAPE); short paperSize = getSuitablePaperSize(jasperPrint); XlsReportConfiguration configuration = getCurrentItemConfiguration(); if (paperSize != -1) { printSetup.setPaperSize(paperSize); }// w ww . j av a 2s . c o m String password = configuration.getPassword(); if (password != null) { sheet.protectSheet(password); } boolean isIgnorePageMargins = configuration.isIgnorePageMargins(); if (jasperPrint.getLeftMargin() != null) { sheet.setMargin((short) 0, LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getLeftMargin())); } if (jasperPrint.getRightMargin() != null) { sheet.setMargin((short) 1, LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getRightMargin())); } if (jasperPrint.getTopMargin() != null) { sheet.setMargin((short) 2, LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getTopMargin())); } if (jasperPrint.getBottomMargin() != null) { sheet.setMargin((short) 3, LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getBottomMargin())); } Integer fitWidth = configuration.getFitWidth(); if (!isValidScale(sheetInfo.sheetPageScale) && fitWidth != null) { printSetup.setFitWidth(fitWidth.shortValue()); sheet.setAutobreaks(true); } Integer fitHeight = configuration.getFitHeight(); if (!isValidScale(sheetInfo.sheetPageScale) && fitHeight != null) { printSetup.setFitHeight(fitHeight.shortValue()); sheet.setAutobreaks(true); } String sheetHeaderLeft = configuration.getSheetHeaderLeft(); if (sheetHeaderLeft != null) { sheet.getHeader().setLeft(sheetHeaderLeft); } String sheetHeaderCenter = configuration.getSheetHeaderCenter(); if (sheetHeaderCenter != null) { sheet.getHeader().setCenter(sheetHeaderCenter); } String sheetHeaderRight = configuration.getSheetHeaderRight(); if (sheetHeaderRight != null) { sheet.getHeader().setRight(sheetHeaderRight); } String sheetFooterLeft = configuration.getSheetFooterLeft(); if (sheetFooterLeft != null) { sheet.getFooter().setLeft(sheetFooterLeft); } String sheetFooterCenter = configuration.getSheetFooterCenter(); if (sheetFooterCenter != null) { sheet.getFooter().setCenter(sheetFooterCenter); } String sheetFooterRight = configuration.getSheetFooterRight(); if (sheetFooterRight != null) { sheet.getFooter().setRight(sheetFooterRight); } RunDirectionEnum sheetDirection = configuration.getSheetDirection(); if (sheetDirection != null) { printSetup.setLeftToRight(sheetDirection == RunDirectionEnum.LTR); sheet.setRightToLeft(sheetDirection == RunDirectionEnum.RTL); } if (sheetInfo.sheetFirstPageNumber != null && sheetInfo.sheetFirstPageNumber > 0) { printSetup.setPageStart((short) sheetInfo.sheetFirstPageNumber.intValue()); printSetup.setUsePage(true); firstPageNotSet = false; } else { Integer documentFirstPageNumber = configuration.getFirstPageNumber(); if (documentFirstPageNumber != null && documentFirstPageNumber > 0 && firstPageNotSet) { printSetup.setPageStart((short) documentFirstPageNumber.intValue()); printSetup.setUsePage(true); firstPageNotSet = false; } } if (!firstPageNotSet && (sheet.getFooter().getCenter() == null || sheet.getFooter().getCenter().length() == 0)) { sheet.getFooter().setCenter("Page " + HeaderFooter.page()); } boolean showGridlines = true; if (sheetInfo.sheetShowGridlines == null) { Boolean documentShowGridlines = configuration.isShowGridLines(); if (documentShowGridlines != null) { showGridlines = documentShowGridlines; } } else { showGridlines = sheetInfo.sheetShowGridlines; } sheet.setDisplayGridlines(showGridlines); maxRowFreezeIndex = 0; maxColumnFreezeIndex = 0; onePagePerSheetMap.put(sheetIndex, configuration.isOnePagePerSheet()); sheetsBeforeCurrentReportMap.put(sheetIndex, sheetsBeforeCurrentReport); }