Example usage for org.apache.poi.hssf.model InternalSheet LeftMargin

List of usage examples for org.apache.poi.hssf.model InternalSheet LeftMargin

Introduction

In this page you can find the example usage for org.apache.poi.hssf.model InternalSheet LeftMargin.

Prototype

short LeftMargin

To view the source code for org.apache.poi.hssf.model InternalSheet LeftMargin.

Click Source Link

Usage

From source file:ro.nextreports.engine.exporter.XlsExporter.java

License:Apache License

protected void newPage() {
    addRegions(xlsSheet, regions, wb);/*from  ww  w.  j  a v a 2 s . c o m*/
    if (hasTemplate()) {
        xlsSheet = wb.getSheetAt(bean.getReportLayout().getTemplateSheet() - 1);
    } else {
        // for a group name inside sheet name when we create a page we do not have the group name yet
        // so we will have to set the name of the previous sheet (see also finishExport where we set the name of the last sheet(s)
        String sheetName = replaceSheetNameParam(bean.getReportLayout().getSheetNames());
        if ((sheetName == null) || sheetName.isEmpty()) {
            sheetName = String.valueOf(page);
        }
        if (sheetNameContainsGroup(bean.getReportLayout().getSheetNames()) && (page > 1)) {
            // current group is for previous sheet page         
            xlsSheet = wb.createSheet(String.valueOf(page));
            wb.setSheetName(page - 2, sheetName);
        } else {
            xlsSheet = wb.createSheet(sheetName);
        }
    }
    xlsSheet.setMargin(InternalSheet.LeftMargin, getInches(bean.getReportLayout().getPagePadding().getLeft()));
    xlsSheet.setMargin(InternalSheet.RightMargin,
            getInches(bean.getReportLayout().getPagePadding().getRight()));
    xlsSheet.setMargin(InternalSheet.TopMargin, getInches(bean.getReportLayout().getPagePadding().getTop()));
    xlsSheet.setMargin(InternalSheet.BottomMargin,
            getInches(bean.getReportLayout().getPagePadding().getBottom()));

    if (bean.getReportLayout().getOrientation() == LANDSCAPE) {
        xlsSheet.getPrintSetup().setLandscape(true);
    }

    setPaperSize();

    patriarch = xlsSheet.createDrawingPatriarch();
    buildHeader();
    buildFooter();
    page++;
    // first page header is written by ResultExporter
    if (bean.getReportLayout().isHeaderOnEveryPage() && (page > 2)) {
        try {
            printHeaderBand();
        } catch (QueryException e) {
            e.printStackTrace();
        }
    }
}