Java Code Examples for org.apache.poi.hssf.usermodel.HSSFPrintSetup#setPaperSize()
The following examples show how to use
org.apache.poi.hssf.usermodel.HSSFPrintSetup#setPaperSize() .
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: ExportEventsImpl.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private HSSFSheet createSheet ( final List<Event> events, final HSSFWorkbook workbook, final List<Field> columns ) { final HSSFSheet sheet = workbook.createSheet ( Messages.ExportImpl_ExcelSheet_Name ); final HSSFHeader header = sheet.getHeader (); header.setLeft ( Messages.ExportImpl_ExcelSheet_Header ); header.setRight ( HeaderFooter.date () + " " + HeaderFooter.time () );//$NON-NLS-1$ final HSSFFooter footer = sheet.getFooter (); footer.setLeft ( String.format ( Messages.ExportImpl_ExcelSheet_Footer_1, events.size () ) ); footer.setRight ( Messages.ExportImpl_ExcelSheet_Footer_2 + HeaderFooter.page () + Messages.ExportImpl_ExcelSheet_Footer_3 + HeaderFooter.numPages () ); makeHeader ( columns, sheet ); final HSSFPrintSetup printSetup = sheet.getPrintSetup (); printSetup.setLandscape ( true ); printSetup.setFitWidth ( (short)1 ); printSetup.setFitHeight ( (short)0 ); printSetup.setPaperSize ( PrintSetup.A4_PAPERSIZE ); sheet.setAutoFilter ( new CellRangeAddress ( 0, 0, 0, columns.size () - 1 ) ); sheet.createFreezePane ( 0, 1 ); sheet.setFitToPage ( true ); sheet.setAutobreaks ( true ); printSetup.setFooterMargin ( 0.25 ); sheet.setMargin ( Sheet.LeftMargin, 0.25 ); sheet.setMargin ( Sheet.RightMargin, 0.25 ); sheet.setMargin ( Sheet.TopMargin, 0.25 ); sheet.setMargin ( Sheet.BottomMargin, 0.5 ); return sheet; }
Example 2
Source File: Excel97Producer.java From ureport with Apache License 2.0 | 4 votes |
private boolean setupPaper(PaperType paperType, HSSFPrintSetup printSetup) { boolean setup=false; switch(paperType){ case A0: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case A1: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case A2: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case A3: printSetup.setPaperSize(HSSFPrintSetup.A3_PAPERSIZE); setup=true; break; case A4: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); setup=true; break; case A5: printSetup.setPaperSize(HSSFPrintSetup.A5_PAPERSIZE); setup=true; break; case A6: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case A7: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case A8: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case A9: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case A10: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case B0: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case B1: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case B2: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case B3: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case B4: printSetup.setPaperSize(HSSFPrintSetup.B4_PAPERSIZE); setup=true; break; case B5: printSetup.setPaperSize(HSSFPrintSetup.B5_PAPERSIZE); setup=true; break; case B6: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case B7: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case B8: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case B9: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case B10: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; case CUSTOM: printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE); break; } return setup; }