IRONSOFTWAREHOME
Excel 列印設定
from ironxl import *

# Load the Excel workbook
workbook = WorkBook.Load("sample.xlsx")
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")
pip install ironxl
Excel 列印設定

Excel 列印設定

IronXL的Excel列印設定功能讓Python開發者能夠在列印或將Excel工作表儲存為PDF之前配置列印設定。 這在生成報告、發票或需要特定格式列印輸出的文件時特別有用。 開發者可以設置帶有動態內容如頁碼和標題的自訂頁眉和頁腳,確保專業的結果。 PrintSetup選項還允許微調邊距、紙張大小和方向,使得文件能夠適應各種印表機和紙張型別。

IronXL提供對列印版面布局的完全控制,包括紙張尺寸如B4、A4和信紙,以及直向和橫向的方向。 啟用黑白列印的選項為低成本列印提供了靈活性。 這項功能使得直接從Python準備高品質列印輸出的Excel文件過程更加簡化。

了解更多有關在Python中管理Excel工作表的資訊

準備好開始了嗎?

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