Excel-to-PDF

👤 Zhenbin Huang 📦 v1.0.0 ⭐ 4.5 ⬇️ 235 下載
📄 辦公效率 免費

📖 技能介紹


name: excel-to-pdf description: Convert Excel (.xlsx) sign-in sheets and rosters to print-ready A4 PDFs with Chinese font support. Use when the user needs to (1) convert an Excel table/roster/sign-in sheet to PDF for printing, (2) generate A4 PDF from .xlsx with table formatting, (3) batch export Excel sheets to PDF with Chinese text. Triggers on requests like "turn this Excel into PDF", "print this table as PDF", "convert xlsx to pdf for printing", "generate a printable PDF from this spreadsheet".


Excel → A4 PDF Converter

Convert Excel spreadsheets to print-ready A4 PDF tables with proper Chinese rendering. Column headers keep their original text (no English translation).

Quick start

Run the bundled script directly on the Excel file:

python scripts/excel_to_pdf_signin.py "C:\path\to\file.xlsx"

The script auto-detects: - Column layout (drops empty/merged placeholder columns) - Page orientation (landscape for ≥7 columns or >35 rows) - Chinese system font (Windows: Microsoft YaHei; macOS: PingFang; Linux: Noto CJK) - Output path (same directory, same name, .pdf extension)

Common options

# Set custom title and wider margins
python scripts/excel_to_pdf_signin.py roster.xlsx --title "簽到表" --margin 12

# Force landscape, higher rows for manual sign-in
python scripts/excel_to_pdf_signin.py signin.xlsx --orientation LANDSCAPE --row-height 8

# Pick specific columns (0-based indices), custom widths
python scripts/excel_to_pdf_signin.py sheet.xlsx --columns 0,1,2,3,7,8 --col-widths 0.1,0.2,0.15,0.2,0.2,0.15

# Larger font for sparse data (e.g. room lists)
python scripts/excel_to_pdf_signin.py rooms.xlsx --font-size 12 --margin 12 --row-height 8

# Explicit output path
python scripts/excel_to_pdf_signin.py data.xlsx --out "D:\output\result.pdf"

# Specific sheet (for multi-sheet workbooks)
python scripts/excel_to_pdf_signin.py multi.xlsx --sheet "1號臺"

# Custom column widths (13 columns, give more space to 學號/電話 to avoid wrapping)
python scripts/excel_to_pdf_signin.py roster.xlsx --col-widths 0.07,0.13,0.10,0.10,0.04,0.05,0.10,0.07,0.08,0.04,0.05,0.09,0.08

Decision guide

Orientation

  • Portrait (default): ≤6 columns and ≤35 rows — typical for sign-in sheets

    7w4.net小蔥技能站收錄全網優質技能,值得收藏。

  • Landscape: ≥7 columns or >35 rows

Margins

  • Crowded tables: --margin 5
  • Normal: --margin 8 (default)
  • Sparse data (room lists, etc.): --margin 12

Row height

  • Dense sign-in sheets: --row-height 6 (default)
  • Hand-writing sign-in sheets (needs space): --row-height 8
  • Room/roster lists (fewer rows): --row-height 10

Column selection

  • The --columns flag takes 0-based indices (A=0, B=1, ...).
  • If omitted, the script auto-drops columns where both header AND all data rows are empty.
  • Typical sign-in sheet (skip sign-number placeholder columns): --columns 0,1,2,3,7,8

Column widths

  • Equal width by default: usable_width / ncols
  • Use --col-widths with ratios summing to ~1.0 to allocate more space to wide columns (學號, 電話, 導師, 院系) and less to narrow ones (性別, 年度).

Full reference

usage: excel_to_pdf_signin.py EXCEL [options]

Options:
  --title TEXT         PDF title (default: derived from filename)
  --orientation PORTRAIT|LANDSCAPE  (default: auto-detect)
  --margin N           Page margin in mm (default: 8)
  --row-height N       Row top/bottom padding in pt (default: 6)
  --columns LIST       Column indices (0-based), comma-separated
  --col-widths LIST    Column width ratios, comma-separated
  --font PATH          Chinese .ttf/.ttc file path
  --font-size N        Cell font size in pt (default: 10)
  --sheet TEXT         Sheet name to process (default: active sheet)
  --out PATH           Output PDF path

Output style

All generated PDFs share: - Blue header row (#4472C4) with white text - White body background with black grid borders - Center-aligned text throughout - Bold bottom border on header row - Original Chinese column headers preserved (no translation)

Dependencies

Install once per environment:

pip install openpyxl reportlab

Requires a Chinese-capable font on the system (auto-detected).

🤖 AI 評測

這個 Skill 質量不錯,能較好地將 Excel 表格轉換成適合列印的 A4 PDF,對中文支援良好,使用簡單。文件寫得很清楚,小白也能上手。優點是自動檢測字型和頁面方向省心,輸出樣式統一美觀。不足是缺少示例檔案參考,且需要手動安裝依賴庫。總體而言是一個實用且功能完整的工具。

📊 多維度評分

適應性4.3
規範性4.3
有效性4.7
可靠性4.3
可信度4.9

📁 包含檔案 (2 個)

📄 SKILL.md 4.1 KB
📄 scripts/excel_to_pdf_signin.py 10.3 KB