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 下載
PM > Install-Package IronXL.Excel
Excel 列印設定

Excel 列印設定

IronXL 中的 Excel 列印設定功能可讓開發人員在列印或儲存 Excel 工作表之前輕鬆配置列印設定。 在產生需要特定列印格式的報表、發票或文件時,此功能尤其有用。 開發人員可以設定自訂頁首和頁腳,以包含動態內容,例如頁碼、標題和其他詳細信息,從而確保專業輸出。 這些PrintSetup 選項還允許對列印邊距、紙張大小和方向進行微調,使文件能夠適應各種打印機和紙張類型。

IronXL 讓開發人員能夠完全控制列印文件的外觀,可以指定紙張尺寸(例如 B4、A4 或信紙尺寸)以及方向選項(縱向或橫向)。 此外,切換到黑白列印或停用彩色列印的功能增加了靈活性,尤其是在經濟高效的列印場景中。 此功能簡化了準備用於高品質列印輸出的 Excel 檔案的過程。

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

準備好開始了嗎?

NuGet 下載次數 2,393,101版本:2026.11剛剛發布