Java Code Examples for org.apache.poi.hssf.usermodel.HSSFPrintSetup#setFitWidth()
The following examples show how to use
org.apache.poi.hssf.usermodel.HSSFPrintSetup#setFitWidth() .
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: JRXlsExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void closeSheet() { if (sheet == null) { return; } HSSFPrintSetup printSetup = sheet.getPrintSetup(); if (isValidScale(sheetInfo.sheetPageScale)) { printSetup.setScale((short)sheetInfo.sheetPageScale.intValue()); } else { XlsReportConfiguration configuration = getCurrentItemConfiguration(); Integer fitWidth = configuration.getFitWidth(); if (fitWidth != null) { printSetup.setFitWidth(fitWidth.shortValue()); sheet.setAutobreaks(true); } Integer fitHeight = configuration.getFitHeight(); fitHeight = fitHeight == null ? (Boolean.TRUE == configuration.isAutoFitPageHeight() ? (pageIndex - sheetInfo.sheetFirstPageIndex) : null) : fitHeight; if (fitHeight != null) { printSetup.setFitHeight(fitHeight.shortValue()); sheet.setAutobreaks(true); } } }
Example 3
Source File: JRXlsMetadataExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void closeSheet() { if (sheet == null) { return; } HSSFPrintSetup printSetup = sheet.getPrintSetup(); if (isValidScale(sheetInfo.sheetPageScale)) { printSetup.setScale((short)sheetInfo.sheetPageScale.intValue()); } else { XlsReportConfiguration configuration = getCurrentItemConfiguration(); Integer fitWidth = configuration.getFitWidth(); if (fitWidth != null) { printSetup.setFitWidth(fitWidth.shortValue()); sheet.setAutobreaks(true); } Integer fitHeight = configuration.getFitHeight(); fitHeight = fitHeight == null ? (Boolean.TRUE == configuration.isAutoFitPageHeight() ? (pageIndex - sheetInfo.sheetFirstPageIndex) : null) : fitHeight; if (fitHeight != null) { printSetup.setFitHeight(fitHeight.shortValue()); sheet.setAutobreaks(true); } } }