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天試用金鑰
無需信用卡或帳戶建立