c# - 如何使用 EPPlus 在工作表上设置页面布局中断

标签 c# export-to-excel epplus

有没有办法使用 EEPlus 设置指定在何处分页?我有以下设置打印机属性的代码,但还没有找到在特定列上设置断点的方法。

// Set printer settings
ws.PrinterSettings.PaperSize = ePaperSize.Tabloid;
ws.PrinterSettings.Orientation = eOrientation.Landscape;
ws.PrinterSettings.FitToPage = true;
ws.PrinterSettings.FitToHeight = 1;
ws.PrinterSettings.FooterMargin = .05M;
ws.PrinterSettings.TopMargin = .05M;
ws.PrinterSettings.LeftMargin = .05M;
ws.PrinterSettings.RightMargin = .05M;

编辑(这有助于解决我的问题)

ws.Column(30).PageBreak = true;
ws.PrinterSettings.PaperSize = ePaperSize.A3;
ws.PrinterSettings.Orientation = eOrientation.Landscape;
ws.PrinterSettings.Scale = 75;  

最佳答案

只需要获取对Row 和/或Column 对象的引用:

ws.Row(20).PageBreak = true;
ws.Column(2).PageBreak = true;

但请记住,FitToPage 可能会抑制这些。

关于c# - 如何使用 EPPlus 在工作表上设置页面布局中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35161565/

相关文章:

excel - EPPlus v4 Worksheet.InsertRow >1024 错误

c# - 阻止并发访问线程池

c# - UpdatePanel 中的 AddThis 控件 - 确保它们在异步回发后正确呈现

c# - 错误 : Reference to type claims it is defined, 但找不到

c# - 在没有警告的情况下使用 ClosedXML 将 Gridview 导出到 Excel : the file you are trying to open is in a different format

c# - Excel 自动化 : Open existing Excel file as "new"

excel - 在 EPPlus 中设置*两者*值和公式

c# - 如何为 EPPlus 中的字体指定颜色?

c# - XAML 群岛,尝试发布 WPF 项目时总是出现错误。还有更多人遇到同样的问题吗?

c# - Wpf 产品在未安装 MS Office 的情况下导出到 Excel