[转]NPOI导出EXCEL 打印设置分页及打印标题

本文转自:http://www.cnblogs.com/Gyoung/p/4483475.html

在用NPOI导出EXCEL的时候设置分页,在网上有查到用sheet1.SetRowBreak(i)方法,但一直都没有起到作用。经过研究是要设置  sheet1.FitToPage = false; 而这个属性默认是true的,怪不得一直设置都不起作用。

设置打印标题用

hssfworkbook.SetRepeatingRowsAndColumns(0, 0, 5, 0, 5);

但最新版本已经有新的方法了。

sheet.RepeatingRows=new CellRangeAddress(0,5,0,5)

[转]NPOI导出EXCEL 打印设置分页及打印标题
            Sheet sheet1 = hssfworkbook.CreateSheet("Sheet1");
sheet1.SetMargin(MarginType.RightMargin, (double)0.5);
sheet1.SetMargin(MarginType.TopMargin, (double)0.6);
sheet1.SetMargin(MarginType.LeftMargin, (double)0.4);
sheet1.SetMargin(MarginType.BottomMargin, (double)0.3); sheet1.PrintSetup.Copies = 3;
sheet1.PrintSetup.NoColor = true;
sheet1.PrintSetup.Landscape = true;
sheet1.PrintSetup.PaperSize = (short)PaperSize.A4; sheet1.PrintSetup.FitHeight = 2;
sheet1.PrintSetup.FitWidth = 3;
sheet1.IsPrintGridlines = true; //是否自适应界面
sheet1.FitToPage = false;
//设置打印标题
hssfworkbook.SetRepeatingRowsAndColumns(0, 0, 5, 0, 5);
[转]NPOI导出EXCEL 打印设置分页及打印标题
上一篇:Webmin LFD to LFI


下一篇:AFNetworking+Python+Flask+pyOpenSSL构建iOS HTTPS客户端&服务器端