Java Code Examples for org.apache.poi.ss.usermodel.Sheet#setPrintGridlines()
The following examples show how to use
org.apache.poi.ss.usermodel.Sheet#setPrintGridlines() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExcelHelp.java From hy.common.report with Apache License 2.0 | 6 votes |
/** * 复制工作表相关参数 * * @author ZhengWei(HY) * @createDate 2017-03-20 * @version v1.0 * * @param i_FromSheet * @param i_ToSheet */ public final static void copySheet(Sheet i_FromSheet ,Sheet i_ToSheet) { // 打印时显示网格线 i_ToSheet.setPrintGridlines( i_FromSheet.isPrintGridlines()); i_ToSheet.setPrintRowAndColumnHeadings(i_FromSheet.isPrintRowAndColumnHeadings()); i_ToSheet.setFitToPage( i_FromSheet.getFitToPage()); // Sheet页自适应页面大小 i_ToSheet.setAutobreaks( i_FromSheet.getAutobreaks()); i_ToSheet.setDisplayZeros( i_FromSheet.isDisplayZeros()); i_ToSheet.setDisplayGuts( i_FromSheet.getDisplayGuts()); // 网格线 i_ToSheet.setDisplayGridlines( i_FromSheet.isDisplayGridlines()); // 冻结线 if ( i_FromSheet.getPaneInformation() != null ) { i_ToSheet.createFreezePane(i_FromSheet.getPaneInformation().getVerticalSplitPosition() ,i_FromSheet.getPaneInformation().getHorizontalSplitPosition() ,i_FromSheet.getPaneInformation().getVerticalSplitLeftColumn() ,i_FromSheet.getPaneInformation().getHorizontalSplitTopRow()); } }
Example 2
Source File: ExportTimetableXLS.java From unitime with Apache License 2.0 | 6 votes |
protected Sheet createSheet(String name) { Sheet sheet = null; try { sheet = (name == null ? iWorkbook.createSheet() : iWorkbook.createSheet(name.replace('/', '-').replace('\\','-').replace('?', ' ').replace('*', ' ').replace(':', '-').replace('[', '(').replace(']', ')'))); } catch (IllegalArgumentException e) { sheet = iWorkbook.createSheet(); } sheet.setDisplayGridlines(false); sheet.setPrintGridlines(false); sheet.setFitToPage(true); sheet.setHorizontallyCenter(true); PrintSetup printSetup = sheet.getPrintSetup(); printSetup.setLandscape(true); sheet.setAutobreaks(true); printSetup.setFitHeight((short)1); printSetup.setFitWidth((short)1); return sheet; }
Example 3
Source File: Util.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
private static void copySheetSettings(Sheet newSheet, Sheet sheetToCopy) { newSheet.setAutobreaks(sheetToCopy.getAutobreaks()); newSheet.setDefaultColumnWidth(sheetToCopy.getDefaultColumnWidth()); newSheet.setDefaultRowHeight(sheetToCopy.getDefaultRowHeight()); newSheet.setDefaultRowHeightInPoints(sheetToCopy.getDefaultRowHeightInPoints()); newSheet.setDisplayGuts(sheetToCopy.getDisplayGuts()); newSheet.setFitToPage(sheetToCopy.getFitToPage()); newSheet.setForceFormulaRecalculation(sheetToCopy.getForceFormulaRecalculation()); PrintSetup sheetToCopyPrintSetup = sheetToCopy.getPrintSetup(); PrintSetup newSheetPrintSetup = newSheet.getPrintSetup(); newSheetPrintSetup.setPaperSize(sheetToCopyPrintSetup.getPaperSize()); newSheetPrintSetup.setScale(sheetToCopyPrintSetup.getScale()); newSheetPrintSetup.setPageStart(sheetToCopyPrintSetup.getPageStart()); newSheetPrintSetup.setFitWidth(sheetToCopyPrintSetup.getFitWidth()); newSheetPrintSetup.setFitHeight(sheetToCopyPrintSetup.getFitHeight()); newSheetPrintSetup.setLeftToRight(sheetToCopyPrintSetup.getLeftToRight()); newSheetPrintSetup.setLandscape(sheetToCopyPrintSetup.getLandscape()); newSheetPrintSetup.setValidSettings(sheetToCopyPrintSetup.getValidSettings()); newSheetPrintSetup.setNoColor(sheetToCopyPrintSetup.getNoColor()); newSheetPrintSetup.setDraft(sheetToCopyPrintSetup.getDraft()); newSheetPrintSetup.setNotes(sheetToCopyPrintSetup.getNotes()); newSheetPrintSetup.setNoOrientation(sheetToCopyPrintSetup.getNoOrientation()); newSheetPrintSetup.setUsePage(sheetToCopyPrintSetup.getUsePage()); newSheetPrintSetup.setHResolution(sheetToCopyPrintSetup.getHResolution()); newSheetPrintSetup.setVResolution(sheetToCopyPrintSetup.getVResolution()); newSheetPrintSetup.setHeaderMargin(sheetToCopyPrintSetup.getHeaderMargin()); newSheetPrintSetup.setFooterMargin(sheetToCopyPrintSetup.getFooterMargin()); newSheetPrintSetup.setCopies(sheetToCopyPrintSetup.getCopies()); Header sheetToCopyHeader = sheetToCopy.getHeader(); Header newSheetHeader = newSheet.getHeader(); newSheetHeader.setCenter(sheetToCopyHeader.getCenter()); newSheetHeader.setLeft(sheetToCopyHeader.getLeft()); newSheetHeader.setRight(sheetToCopyHeader.getRight()); Footer sheetToCopyFooter = sheetToCopy.getFooter(); Footer newSheetFooter = newSheet.getFooter(); newSheetFooter.setCenter(sheetToCopyFooter.getCenter()); newSheetFooter.setLeft(sheetToCopyFooter.getLeft()); newSheetFooter.setRight(sheetToCopyFooter.getRight()); newSheet.setHorizontallyCenter(sheetToCopy.getHorizontallyCenter()); newSheet.setMargin(Sheet.LeftMargin, sheetToCopy.getMargin(Sheet.LeftMargin)); newSheet.setMargin(Sheet.RightMargin, sheetToCopy.getMargin(Sheet.RightMargin)); newSheet.setMargin(Sheet.TopMargin, sheetToCopy.getMargin(Sheet.TopMargin)); newSheet.setMargin(Sheet.BottomMargin, sheetToCopy.getMargin(Sheet.BottomMargin)); newSheet.setPrintGridlines(sheetToCopy.isPrintGridlines()); newSheet.setRowSumsBelow(sheetToCopy.getRowSumsBelow()); newSheet.setRowSumsRight(sheetToCopy.getRowSumsRight()); newSheet.setVerticallyCenter(sheetToCopy.getVerticallyCenter()); newSheet.setDisplayFormulas(sheetToCopy.isDisplayFormulas()); newSheet.setDisplayGridlines(sheetToCopy.isDisplayGridlines()); newSheet.setDisplayRowColHeadings(sheetToCopy.isDisplayRowColHeadings()); newSheet.setDisplayZeros(sheetToCopy.isDisplayZeros()); newSheet.setPrintGridlines(sheetToCopy.isPrintGridlines()); newSheet.setRightToLeft(sheetToCopy.isRightToLeft()); newSheet.setZoom(1, 1); copyPrintTitle(newSheet, sheetToCopy); }
Example 4
Source File: ExcelPrinterBase.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected void configureSheetPaperSize( final Sheet sheet, final PhysicalPageBox page ) { Configuration config = getConfig(); final String paper = config.getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.Paper" ); final String orientation = config .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.PaperOrientation" ); final short scale = (short) ParserUtil .parseInt( config .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.PrintScaleFactor" ), 100 ); final short hres = (short) ParserUtil .parseInt( config .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.PrintHorizontalResolution" ), -1 ); final short vres = (short) ParserUtil .parseInt( config .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.PrintVerticalResolution" ), -1 ); final boolean noColors = "true".equals( config .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.PrintNoColors" ) ); final boolean notes = "true".equals( config .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.PrintNotes" ) ); final boolean usePage = "true".equals( config .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.PrintUsePage" ) ); final boolean draft = "true".equals( config .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.PrintDraft" ) ); final PrintSetup printSetup = sheet.getPrintSetup(); ExcelPrintSetupFactory.performPageSetup( printSetup, page, paper, orientation ); printSetup.setScale( scale ); printSetup.setNoColor( noColors ); printSetup.setNotes( notes ); printSetup.setUsePage( usePage ); if ( hres > 0 ) { printSetup.setHResolution( hres ); } if ( vres > 0 ) { printSetup.setVResolution( vres ); } printSetup.setDraft( draft ); final boolean displayGridLines = "true" .equals( config .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.GridLinesDisplayed" ) ); final boolean printGridLines = "true" .equals( config .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.output.table.xls.GridLinesPrinted" ) ); sheet.setDisplayGridlines( displayGridLines ); sheet.setPrintGridlines( printGridLines ); }