How to Manipulate Excel Spreadsheets with Python and Claude Skills: A Complete Guide

The ComposioHQ/awesome-claude-skills repository provides a three-layer architecture—combining high-level toolkits, Python libraries (pandas and openpyxl), and a formula recalculation engine—to create, modify, format, and validate Excel spreadsheets with zero-error guarantees.

To manipulate Excel spreadsheets programmatically, developers need more than basic file I/O; they require robust validation, formatting standards, and support for both local files and cloud platforms. The awesome-claude-skills repository delivers a production-grade stack designed specifically for Claude skills, enabling automated workflows that handle everything from simple data entry to complex financial modeling. This guide explores the architecture, implementation patterns, and code examples necessary to build reliable Excel automation.

Three-Layer Architecture for Excel Manipulation

The repository organizes Excel functionality into distinct layers that separate high-level orchestration from low-level cell manipulation.

High-Level Toolkit: Excel Automation

The Excel Automation skill wraps Composio’s Excel and Google Sheets toolkits, exposing standardized commands such as EXCEL_CREATE_WORKBOOK, GOOGLESHEETS_BATCH_UPDATE, and GOOGLESHEETS_FORMAT_CELL. These abstractions handle authentication, API limits, and platform-specific quirks, allowing Claude to manipulate Excel spreadsheets across Microsoft 365 and Google Workspace without vendor lock-in.

Python Libraries: pandas and openpyxl

For bulk operations and fine-grained control, the stack relies on two core libraries:

  • pandas: Handles large-scale data analysis via pandas.read_excel() and vectorized operations.
  • openpyxl: Manages low-level cell manipulation, formula insertion, styling, and workbook structure.

According to document-skills/xlsx/SKILL.md, these libraries work in tandem: pandas for rapid data extraction and transformation, openpyxl for preserving formatting and inserting Excel-native formulas.

Formula Recalculation Engine

Because openpyxl stores formulas as static strings without evaluation, the recalc.py script invokes LibreOffice in headless mode to execute every formula and surface error codes. Located at document-skills/xlsx/recalc.py, this engine validates that no #REF!, #DIV/0!, or #VALUE! errors remain before finalizing a file.

Production Workflow to Manipulate Excel Spreadsheets

The repository defines a six-step workflow that ensures data integrity and visual consistency.

  1. Create or Load Workbook: Use EXCEL_CREATE_WORKBOOK for OneDrive/SharePoint files or openpyxl.Workbook()/load_workbook() for local processing.
  2. Read and Analyze: Query data with pandas.read_excel() for speed; use openpyxl.load_workbook(data_only=True) to inspect calculated values.
  3. Write Data and Formulas: Insert values and Excel formulas (e.g., =SUM(B2:B10)) via openpyxl cell assignments or GOOGLESHEETS_BATCH_UPDATE for cloud sheets.
  4. Format Cells: Apply styling using openpyxl.styles.Font, PatternFill, and Alignment, or invoke GOOGLESHEETS_FORMAT_CELL for Google Sheets.
  5. Recalculate and Validate: Execute python recalc.py <file.xlsx> to generate a JSON error report.
  6. Iterate: Correct any errors surfaced by the recalculation engine, then rerun validation.

Code Examples for Excel Automation

The following snippets from the repository demonstrate practical implementations.

Creating Formatted Workbooks with openpyxl

This example from document-skills/xlsx/SKILL.md creates a new workbook with standardized financial-model color coding:

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

wb = Workbook()
ws = wb.active
ws.title = "Summary"

# Header row with bold blue text on yellow background

header = ["Item", "Quantity", "Unit Price", "Total"]
for col, title in enumerate(header, start=1):
    cell = ws.cell(row=1, column=col, value=title)
    cell.font = Font(bold=True, color="0000FF")        # Blue

    cell.fill = PatternFill("solid", start_color="FFFF00")  # Yellow

    cell.alignment = Alignment(horizontal="center")

# Data rows with formulas

data = [
    ["Widget", 10, 2.5, "=B2*C2"],
    ["Gadget", 5, 4.0, "=B3*C3"],
]
for r_idx, row in enumerate(data, start=2):
    for c_idx, value in enumerate(row, start=1):
        ws.cell(row=r_idx, column=c_idx, value=value)

# Auto-size columns

for col in ws.columns:
    ws.column_dimensions[col[0].column_letter].width = 15

wb.save("report.xlsx")

After saving, pass report.xlsx to recalc.py to evaluate the formulas.

Upserting Data into Existing Files

This pattern mimics the GOOGLESHEETS_UPSERT_ROWS toolkit command using pure openpyxl:

from openpyxl import load_workbook

wb = load_workbook("budget.xlsx")

# Create sheet if missing

if "Q4" not in wb.sheetnames:
    ws = wb.create_sheet(title="Q4")
else:
    ws = wb["Q4"]

# Upsert logic based on key column

key_col = "A"
new_rows = [
    ["Widget", 12, 2.5],
    ["Gizmo", 7, 3.75],
]

existing_keys = {ws[f"{key_col}{row}"].value for row in range(2, ws.max_row + 1)}

for row_vals in new_rows:
    if row_vals[0] in existing_keys:
        # Update existing row

        for r in range(2, ws.max_row + 1):
            if ws[f"{key_col}{r}"].value == row_vals[0]:
                ws[f"B{r}"] = row_vals[1]
                ws[f"C{r}"] = row_vals[2]
                break
    else:
        ws.append(row_vals)

wb.save("budget_updated.xlsx")

Validating Formulas with recalc.py

Execute the validation script to ensure formula integrity:

python recalc.py budget_updated.xlsx 30

The script outputs JSON detailing error counts and locations:

{
  "status": "success",
  "total_errors": 0,
  "total_formulas": 23
}

If errors exist, the error_summary field lists each error type and cell coordinates, enabling targeted fixes.

Automating Google Sheets via Toolkit

For cloud-based workflows defined in composio-skills/excel-automation/SKILL.md, use the toolkit syntax:

Tool: GOOGLESHEETS_BATCH_UPDATE
Arguments:
  spreadsheet_id: "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
  sheet_name: "Sheet1"
  values:
    - ["Date", "Revenue", "Cost"]
    - ["2024-01-01", 120000, 80000]
    - ["2024-02-01", 135000, 90000]
  first_cell_location: "A1"

The toolkit applies USER_ENTERED parsing, ensuring dates and numbers interpret correctly without manual formatting.

Formatting Cells in Google Sheets

Apply visual styling via the toolkit using RGB float values (0-1 scale):

Tool: GOOGLESHEETS_FORMAT_CELL
Arguments:
  spreadsheet_id: "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
  range: "A1:C1"
  sheet_name: "Sheet1"
  bold: true
  fontSize: 12
  red: 0.2
  green: 0.4
  blue: 0.9

Architectural Best Practices

The repository enforces strict standards to maintain professional-quality spreadsheets.

Zero-Error Guarantee

Every Excel model must exit the pipeline free of error codes. The recalc.py script enforces this by scanning all cells after edits and returning a concise JSON report. As documented in document-skills/xlsx/SKILL.md, this guarantee prevents silent failures in financial models where #REF! errors could cascade into incorrect calculations.

Preserve Existing Templates

When updating templates, the skill respects original layouts, colors, and naming conventions. The implementation never overwrites user-defined styling unless explicitly instructed, ensuring that branded reports and formatted tables remain intact during data refreshes.

Financial-Model Color Coding

Standardized color rules baked into the guidance keep models readable and auditable:

  • Blue: Input cells
  • Black: Formulas
  • Green: Internal links
  • Red: External links
  • Yellow: Key assumptions

This scheme appears in the openpyxl styling examples and toolkit formatting commands, creating visual consistency across automated outputs.

Summary

  • The awesome-claude-skills repository provides a complete stack to manipulate Excel spreadsheets through high-level toolkits, Python libraries, and validation engines.
  • openpyxl handles low-level cell manipulation and styling, while pandas manages bulk data analysis.
  • The recalc.py script eliminates formula errors by evaluating spreadsheets via LibreOffice and reporting issues as JSON.
  • Toolkit commands like GOOGLESHEETS_BATCH_UPDATE enable cloud automation across Microsoft Excel and Google Sheets.
  • Strict color-coding standards and zero-error validation ensure production-grade financial modeling.

Frequently Asked Questions

What Python libraries does the awesome-claude-skills repository use to manipulate Excel spreadsheets?

The repository primarily uses pandas for high-performance data reading and analysis via pandas.read_excel(), and openpyxl for low-level workbook manipulation including cell writing, formula insertion, and styling. These libraries appear throughout document-skills/xlsx/SKILL.md as the recommended stack for local file processing.

How does recalc.py ensure formula accuracy in Excel files?

Because openpyxl stores formulas as strings without calculating results, recalc.py invokes LibreOffice in headless mode to evaluate every formula in the spreadsheet. It returns a JSON report listing error counts and specific cell locations for any #REF!, #DIV/0!, or #VALUE! errors, enforcing a zero-error guarantee before finalizing files.

Can I use these skills with Google Sheets instead of Microsoft Excel?

Yes. The Excel Automation skill in composio-skills/excel-automation/SKILL.md provides toolkit commands such as GOOGLESHEETS_BATCH_UPDATE and GOOGLESHEETS_FORMAT_CELL that manipulate Google Sheets using the same architectural patterns as local Excel files. The repository abstracts platform differences, allowing Claude skills to work across both ecosystems.

According to document-skills/xlsx/SKILL.md, financial models should follow a strict color convention: blue for manual inputs, black for formulas, green for internal links, red for external links, and yellow for key assumptions. This standardization ensures that automated spreadsheets remain auditable and visually consistent with professional modeling practices.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →