This project is read-only.

Page padding, margin, Cell padding

Oct 5, 2009 at 4:44 AM

I want to set page when print. I used:

   sheet1.PrintSetup.FooterMargin = 0;

   sheet1.PrintSetup.HeaderMargin = 0;

   sheet1.PrintSetup.Scale = 100;

   sheet1.PrintSetup.FitHeight = 1;

   sheet1.PrintSetup.FitWidth = 1;

But I view print view, Margin top and bottom very large. I want to it is small.

And I want to set cell padding and word wrap, Please give me how to?

Thanks, Toannh

Jan 22, 2010 at 3:41 PM

After hours looking around the PrintSetup, I looked at the sheet object...
You should try with this, it's working here :

  sheet1.SetMargin(HSSFSheet.TopMargin, 0.1);
  sheet1.SetMargin(HSSFSheet.BottomMargin, 0.1);
  sheet1.SetMargin(HSSFSheet.LeftMargin, 0.1);
  sheet1.SetMargin(HSSFSheet.RightMargin, 0.1);

Code example for printing was a little bit useless for our case BTW.

Feb 2, 2010 at 11:45 AM

For NPOI 1.2.2 use

using NPOI.HSSF.Model;


sheet1.SetMargin(MarginType.TopMargin, 0.1);
sheet1.SetMargin(MarginType.BottomMargin, 0.1);
sheet1.SetMargin(MarginType.LeftMargin, 0.1);
sheet1.SetMargin(MarginType.RightMargin, 0.1);