【发布时间】:2016-03-08 05:37:26
【问题描述】:
我当前的项目使用 EPPlus 创建 Excel 文件。这些文件由用户打印,我试图强制 Excel 文件仅打印在一个 A4 页面上,无论内容的宽度如何。
实际上,打印文件时,它需要两页,而第二页只包含一列。
我的代码:
ws.PrinterSettings.Orientation = eOrientation.Landscape;
ws.PrinterSettings.PrintArea = ws.Cells[ws_dimension_adress];
ws.PrinterSettings.TopMargin= 0;
ws.PrinterSettings.RightMargin = 0;
ws.PrinterSettings.BottomMargin = 0;
ws.PrinterSettings.LeftMargin = 0;
ws.Cells[ws_dimension_adress].AutoFitColumns();
ws.Cells[ws_dimension_adress].Style.Font.Size = 9;
结果: 我的代码提供的结果
我需要什么:
我搜索了诸如“自动适应 A4 页面”之类的东西,但还没有解决方案。
备注:所有列都是必需的。我不能在创建文件之前简单地删除一个。
感谢您的帮助!
【问题讨论】:
标签: c# asp.net excel printing epplus