Excel打印设置
using IronXL;
using IronXL.Printing;

WorkBook workBook = WorkBook.Load("sample.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Set the print header and footer of the worksheet
workSheet.Header.Center = "My document";
workSheet.Footer.Center = "Page &P of &N";

// Set the header margin
workSheet.PrintSetup.HeaderMargin = 2.33;

// Set the size of the paper
// Paper size enum represents different sizes of paper
workSheet.PrintSetup.PaperSize = PaperSize.B4;

// Set the print orientation of the worksheet
workSheet.PrintSetup.PrintOrientation = PrintOrientation.Portrait;

// Set black and white printing
workSheet.PrintSetup.NoColor = true;

workBook.SaveAs("PrintSetup.xlsx");
NuGet Download
PM > Install-Package IronXL.Excel
Excel打印设置

Excel打印设置

IronXL 中的 Excel 打印设置功能允许开发人员在打印或保存 Excel 工作表之前轻松配置打印设置。 在生成需要特定打印格式的报告、发票或文档时,此功能尤其有用。 开发人员可以设置自定义页眉和页脚,以包含动态内容,例如页码、标题和其他详细信息,从而确保专业输出。 PrintSetup选项还允许微调打印边距、纸张大小和方向,使文档适应各种打印机和纸张类型。

IronXL 让开发人员能够完全控制打印文档的外观,可以指定纸张尺寸(例如 B4、A4 或信纸尺寸)以及方向选项(纵向或横向)。 此外,切换到黑白打印或禁用彩色打印的功能增加了灵活性,尤其是在经济高效的打印场景中。 此功能简化了准备用于高质量打印输出的 Excel 文件的过程。

了解更多关于使用 C# 管理 Excel 工作表的信息
在 GitHub 上查看

准备开始了吗?

Nuget Downloads 2,362,812版本:2026.11刚刚发布