如何透過提示詞自動產生每月 Excel 報表
何時使用: 每月底需要更新「那份大家都在問的試算表」時。
前置條件
- uv installed — curl -LsSf https://astral.sh/uv/install.sh | sh
- A source of truth (CSV, DB query, or prior month's file) — 匯出為 CSV,或搭配 postgres MCP 使用
步驟
-
建立活頁簿Create /reports/2026-04.xlsx with tabs 'Summary', 'Revenue', 'Costs', 'Charts'.✓ 已複製→ 檔案已建立,工作表存在
-
填入資料Fill 'Revenue' from /data/apr-revenue.csv; add a total row with SUM formulas.✓ 已複製→ 資料列與合計列已存在
-
新增圖表On 'Charts' tab add a line chart of daily revenue from 'Revenue' A2:B31 titled 'April Revenue'.✓ 已複製→ 在 Excel 中開啟後圖表可見
-
格式化On 'Summary', bold headers, apply thousands separators to currency, and conditional-format any red (negative) values.✓ 已複製→ 檔案呈現專業格式
結果: 一份具備即時公式與圖表、可直接交付審閱的 .xlsx 檔案。
注意事項
- 透過提示詞貼入 10 萬列資料會撐爆 context window — 讓 MCP 直接從磁碟讀取 CSV,而非將數值貼入提示詞
- openpyxl 寫入的樞紐分析表在某些 Excel 版本開啟時不會自動重新整理 — 指示使用者右鍵點選「重新整理」;或改用公式型摘要替代