Bug 52574 - Sheet.HeaderMargin & Sheet.FooterMargin only supported in XSSF
Summary: Sheet.HeaderMargin & Sheet.FooterMargin only supported in XSSF
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-01 18:33 UTC by Greg Jungman
Modified: 2012-02-27 17:10 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Jungman 2012-02-01 18:33:44 UTC
The below code works in Excel 2007 (XSSF) but not in 2003 (HSSF).  Excel 2003 has header and footer margins.

Code:
        sheet.setMargin(Sheet.HeaderMargin, headerMargin);
        sheet.setMargin(Sheet.FooterMargin, footerMargin);

Error Stack Trace:


java.lang.IllegalArgumentException: Unknown margin constant:  4

        at org.apache.poi.hssf.record.aggregates.PageSettingsBlock.getMarginRec(

PageSettingsBlock.java:413)

        at org.apache.poi.hssf.record.aggregates.PageSettingsBlock.setMargin(Pag

eSettingsBlock.java:442)

        at org.apache.poi.hssf.usermodel.HSSFSheet.setMargin(HSSFSheet.java:1072

)

        at com.utilinc.planner.b2.b2ii.B2iiToExcel.toExcel(B2iiToExcel.java:1491
Comment 1 Yegor Kozlov 2012-02-27 15:34:11 UTC
Fixed in r1294181

Actually you could set header/footer margins in HSSF, but in a different manner:

        sheet.getPrintSetup().setFooterMargin(margin);
and
        sheet.getPrintSetup().setHeaderMargin(margin);

Now setMargin correctly handles all types, the same behavior as in XSSF.

Yegor
Comment 2 Greg Jungman 2012-02-27 17:10:47 UTC
Thanks!!!!