Example usage for org.apache.poi.ss.usermodel Sheet HeaderMargin

List of usage examples for org.apache.poi.ss.usermodel Sheet HeaderMargin

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Sheet HeaderMargin.

Prototype

short HeaderMargin

To view the source code for org.apache.poi.ss.usermodel Sheet HeaderMargin.

Click Source Link

Usage

From source file:uk.co.spudsoft.birt.emitters.excel.StyleManagerXUtils.java

License:Open Source License

@Override
public void prepareMarginDimensions(Sheet sheet, IPageContent page) {
    double headerHeight = 0.5;
    double footerHeight = 0.5;
    if ((page.getHeaderHeight() != null) && isAbsolute(page.getHeaderHeight())) {
        headerHeight = page.getHeaderHeight().convertTo(DimensionType.UNITS_IN);
        sheet.setMargin(Sheet.HeaderMargin, headerHeight);
    }/*from   w ww  .j  av  a  2  s .  co m*/
    if ((page.getFooterHeight() != null) && isAbsolute(page.getFooterHeight())) {
        footerHeight = page.getFooterHeight().convertTo(DimensionType.UNITS_IN);
        sheet.setMargin(Sheet.FooterMargin, footerHeight);
    }
    if ((page.getMarginBottom() != null) && isAbsolute(page.getMarginBottom())) {
        sheet.setMargin(Sheet.BottomMargin,
                footerHeight + page.getMarginBottom().convertTo(DimensionType.UNITS_IN));
    }
    if ((page.getMarginLeft() != null) && isAbsolute(page.getMarginLeft())) {
        sheet.setMargin(Sheet.LeftMargin, page.getMarginLeft().convertTo(DimensionType.UNITS_IN));
    }
    if ((page.getMarginRight() != null) && isAbsolute(page.getMarginRight())) {
        sheet.setMargin(Sheet.RightMargin, page.getMarginRight().convertTo(DimensionType.UNITS_IN));
    }
    if ((page.getMarginTop() != null) && isAbsolute(page.getMarginTop())) {
        sheet.setMargin(Sheet.TopMargin, headerHeight + page.getMarginTop().convertTo(DimensionType.UNITS_IN));
    }
}