Skip to content
excel-formula-analyzer logo

Excel Formula Analyzer

excel-formula-analyzer

Analyze Excel spreadsheet formulas to build dependency DAGs (Directed Acyclic Graphs) and understand calculation chains. This skill should be used when the user wants to reverse-engineer Excel formula dependencies, trace how values are calculated from inputs to outputs, validate formula logic, or...

SKILL.md

Full skill instructions

Excel Formula Analyzer

Quick Start

To trace formula dependencies in an Excel workbook:

python .claude/​skills/​excel-formula-analyzer/​scripts/​trace-formula-dag.py "Workbook.xlsx" "Sheet Name" \
    --table MyTable \
    --columns 16-36,57,58,59

Sample output:

[Col 36] End of Harvest
     = =IF([@[Actual End of Harvest]]="",[@[Expected End of Harvest]],[@[Actual ...
  Depends on: ['Actual End of Harvest', 'Expected End of Harvest']
  |- [31] Expected End of Harvest
       = =[@[Expected Beginning of Harvest]]+[@[Harvest Window]]+[@[Additional ...
       |- [28] Expected Beginning of Harvest (calculated)
       |- [59] Harvest Window (INPUT)
       |- [33] Additional Days of Harvest (INPUT)

Overview

This skill enables analysis of Excel spreadsheet formulas to understand how calculations flow from inputs to outputs. It builds dependency graphs (DAGs) from formula references and can help create equivalent code implementations.

When to Use This Skill

  • Tracing how a specific cell's value is calculated
  • Building a complete dependency graph of formula relationships
  • Reverse-engineering business logic embedded in spreadsheets
  • Creating TypeScript/​Python implementations that replicate Excel calculations
  • Validating that code implementations match Excel behavior

Core Workflow

Step 1: Load the Workbook

Load with data_only=False to get formulas instead of computed values:

import openpyxl
wb = openpyxl.load_workbook("spreadsheet.xlsx", data_only=False)
ws = wb["SheetName"]

Step 2: Parse Structured Table References

Excel tables use structured references like TableName[[#This Row],[Column]]. See references/​structured-refs.md for complete syntax details.

Key patterns:

  • Table[[#This Row],[Column]] - Same-row reference
  • Table[Column] - Full column reference (used in XLOOKUP)

Step 3: Build the DAG

Run the trace script to analyze dependencies:

python .claude/​skills/​excel-formula-analyzer/​scripts/​trace-formula-dag.py "file.xlsx" "Sheet" --columns 16-36

Step 4: Implement in Code

Translate formulas to TypeScript/​Python using patterns in references/​formula-patterns.md.

What Didn't Work (Lessons Learned)

The formulas Library

The Python formulas library can parse Excel formulas into ASTs, but fails on structured table references:

Error: Not a valid formula: =MEDIAN(Crops[Revenue - Copy])

The library expects A1-style references and cannot handle TableName[Column] syntax.

xlwings COM Interface

xlwings can use Excel's native DirectPrecedents API, but:

  • Requires Excel to be installed (Windows/​Mac only)
  • Can timeout on large workbooks
  • COM interface can be unreliable

Converting Table References to A1 Notation

While Excel can convert structured refs to A1 notation (Table menu > Convert to Range), this destroys the semantic meaning and makes the formulas harder to understand.

Key Nuances

Excel Date Handling

Excel stores dates as numbers (days since 1900-01-01, with a leap year bug):

from datetime import datetime, timedelta

def excel_to_date(excel_num):
    if excel_num is None or excel_num < 1:
        return None
    return datetime(1899, 12, 30) + timedelta(days=excel_num)

Formula vs Value Reading

  • data_only=True: Returns calculated values (requires the file was saved with calculations)
  • data_only=False: Returns formulas as strings

To get both, load the workbook twice.

COALESCE Patterns

Excel implements COALESCE with IF(ISBLANK()). In code, use nullish coalescing:

const value = actualValue ?? plannedValue;

Resources

scripts/

  • trace-formula-dag.py - Build formula DAGs with CLI arguments for table name and columns
  • validate-calculator.py - Validate code implementations against Excel values

references/

  • structured-refs.md - Complete guide to Excel structured table reference syntax, parsing patterns, and gotchas
  • formula-patterns.md - Common Excel formulas and their TypeScript/​Python equivalents

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View