#region 设置页边距 //sheet.SetMargin(MarginType.LeftMargin, (double)0.6 / 3); //sheet.SetMargin(MarginType.RightMargin, (double)0.6 / 3); //sheet.SetMargin(MarginType.BottomMargin, (double)0.6 / 3); //sheet.SetMargin(MarginType.TopMargin, (double)0.6 / 3); //sheet.FitToPage = true; #endregion
NPOI.SS.UserModel.ISheet sheet = null; sheet.PrintSetup.Landscape = true; //Landscape是布尔类型的,在英语中是横向的意思 sheet.FitToPage = false; //是否自适应界面 sheet.PrintSetup.Scale = 100; //缩放设置 PrintSetup.Scale应该被设置为0-100之间的值,而不是小数 sheet.IsPrintGridlines = true; //打印是否带网格线 sheet.PrintSetup.PaperSize = 9; //A4 210 x 297 mm sheet.SetMargin(NPOI.SS.UserModel.MarginType.RightMargin, (double)0.3); sheet.SetMargin(NPOI.SS.UserModel.MarginType.TopMargin, (double)0.6); sheet.SetMargin(NPOI.SS.UserModel.MarginType.LeftMargin, (double)0.3); sheet.SetMargin(NPOI.SS.UserModel.MarginType.BottomMargin, (double)0.6);