← 返回
未分类 中文

Excel Builder

Build .xlsx files with formulas, merged cells, data validation, conditional formatting, pivot tables, and charts. Use when creating Excel spreadsheets, finan...
构建包含公式、合并单元格、数据验证、条件格式、数据透视表和图表的 .xlsx 文件,适用于创建 Excel 电子表格,尤其是财务场景。
jimmy974 jimmy974 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 415
下载
💾 0
安装
1
版本
#latest

概述

Excel Builder

Builds structured .xlsx files programmatically using Python libraries (openpyxl or xlsxwriter).

When to Use This Skill

  • Creating Excel spreadsheets with formulas and calculated fields
  • Building financial tables, budgets, or invoices
  • Generating data entry forms with validation and dropdowns
  • Producing reports with charts (bar, line, pie, scatter)
  • Exporting structured data with conditional formatting or color coding
  • Building pivot-ready data tables

Core Workflow

  1. Choose library — Use openpyxl for reading/modifying existing files; use xlsxwriter for new write-only files with rich charts
  2. Design structure — Define sheets, columns, headers, and data rows before writing
  3. Write data — Populate cells row by row; apply number formats ("#,##0.00", "YYYY-MM-DD")
  4. Add formulas — Use Excel formula strings: =SUM(B2:B100), =IF(A2>0, "Yes", "No")
  5. Format — Apply styles: bold headers, column widths, merged cells, fill colors, borders
  6. Validate — Add data validation (dropdown lists, numeric ranges) where applicable
  7. Charts — Add charts referencing data ranges; set titles and axis labels
  8. Save and verify — Save to output path; confirm file exists and is non-zero bytes

Key Patterns

openpyxl (read/write existing)

from openpyxl import Workbook, load_workbook
from openpyxl.styles import Font, PatternFill, Alignment

wb = Workbook()
ws = wb.active
ws.title = "Report"
ws["A1"] = "Revenue"
ws["A1"].font = Font(bold=True, size=12)
ws.column_dimensions["A"].width = 20
wb.save("output.xlsx")

xlsxwriter (new files with charts)

import xlsxwriter
wb = xlsxwriter.Workbook("output.xlsx")
ws = wb.add_worksheet("Summary")
bold = wb.add_format({"bold": True, "bg_color": "#4472C4", "font_color": "white"})
ws.write("A1", "Month", bold)
chart = wb.add_chart({"type": "column"})
chart.add_series({"values": "=Summary!$B$2:$B$13", "name": "Revenue"})
ws.insert_chart("D2", chart)
wb.close()

Error Handling

  • If openpyxl not installed: pip install openpyxl
  • If xlsxwriter not installed: pip install xlsxwriter
  • Always wrap wb.save() in try/except; report path conflicts
  • Verify output with os.path.getsize(path) > 0 before returning

Output

Return the absolute path to the saved .xlsx file. If generating multiple sheets, list each sheet name and row count in a brief summary.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-03 11:27 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

office-efficiency

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 932 📥 187,326
office-efficiency

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 387 📥 147,343
professional

Financial Model Builder

jimmy974
构建收入模型、定价工具和预测电子表格,包含假设、情景和预测。用于创建财务预测和单位经济等场景。
★ 0 📥 528