IRONSOFTWAREHOME
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");
Imports IronXL
Imports IronXL.Printing

Dim workBook As WorkBook = WorkBook.Load("sample.xlsx")
Dim workSheet As 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,237,574版本:2026.9刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥
无需信用卡或创建账户