Skip to content

About

AI coding agent embedded in Excel — local execution, full agentic loop, plain-English data transforms

Resources

Stars

6 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Built with OpenCode Python License

opencode-excel

An AI agent that lives inside Excel. Select cells, describe what you want in plain English, and watch OpenCode write and run Python to transform your data — with automatic self-correction on errors. No copy-paste, no context-switching, no debugging by hand.

How it's different: Not a chat sidebar that suggests formulas. A full agentic loop — the AI writes code, runs it, reads the output, fixes bugs, and retries — all inside a local sandbox. You only see the final result in your sheet.

Demo

Dates normalized Outliers flagged Summary stats
"normalize these dates to MM/DD/YYYY" "highlight outliers in red" "mean, median, std in F1:G10"

Architecture

┌─────────────────┐     HTTP + WS      ┌────────────────┐     subprocess     ┌──────────┐
│  Excel Add-in   │ ◄────────────────► │  Bridge Server  │ ◄───────────────► │ OpenCode │
│  (React + O.js) │   localhost:7474   │  (Node.js)      │    temp dir       │  (Python) │
└────────┬────────┘                    └────────────────┘                    └──────────┘
         │ Office.js                                                                 │
         ▼                                                                           ▼
  ┌──────────┐                                                              ┌──────────────┐
  │  Excel   │                                                              │  sandbox/venv│
  │  sheet   │                                                              │  pandas,numpy│
  └──────────┘                                                              └──────────────┘

Everything runs locally. Only the instruction + selected range go to your LLM provider.

Quick Start

Prerequisites

  • Node.js >= 18
  • Python >= 3.9
  • OpenCode CLI installed and configured with an API provider
  • Excel (web or desktop) with sideloading enabled

Setup

git clone https://github.com/MohammadAlMasalmeh/opencode-excel.git
cd opencode-excel
npm install && npm run setup      # installs JS deps + creates Python venv

Run

# Terminal 1 — Bridge server
npm run bridge

# Terminal 2 — Add-in dev server (with HTTPS)
npm run addin:dev

Load in Excel

Excel on the web: Insert → Add-ins → Upload My Add-in → select addin/manifest.xml

Excel desktop (macOS):

# One-time cert trust:
sudo mkcert -install
open https://localhost:3000/taskpane/index.html   # accept cert warning

# Sideload:
bash scripts/sideload-desktop.sh

Then click OpenCode in the Home ribbon.

Use

  1. Select a data range in Excel
  2. Type what you want in the task pane (e.g. "flag outliers in column C and highlight them red")
  3. Click Run
  4. Watch the agent write Python, run it, fix any errors, and write results back to your sheet

What it can do (MVP)

  • Set values — add new columns, transform existing data
  • Format cells — fill colors, bold, font size
  • Number formats — currency, dates, percentages
  • Summary cells — write computed results to specific cells
  • Charts and graphs — create native Excel column, bar, line, pie, scatter, area, and doughnut charts

Project structure

opencode-excel/
├── addin/               # Office Add-in (React + TypeScript + Office.js)
│   ├── src/taskpane/    # Main UI components
│   ├── src/lib/         # Office.js wrappers, bridge client, ops
│   └── src/commands/    # Ribbon button handlers
├── bridge/              # Local bridge server (Express + WebSocket)
│   └── src/             # Session management, OpenCode spawner, validation
├── sandbox/             # Python environment (pandas, numpy, openpyxl, scipy)
│   ├── requirements.txt
│   └── setup.sh
└── scripts/             # Desktop sideload helper

Tech stack

Layer Tech
Add-in UI TypeScript, React, Office.js
Add-in build Vite
Bridge server Node.js, Express, ws
Agent OpenCode CLI
Execution Python 3 (pandas, numpy, openpyxl, scipy)

How the agent loop works

  1. Bridge writes input.csv + system prompt to a temp dir
  2. OpenCode generates script.py, runs it, reads output
  3. If the script errors, OpenCode reads stderr, patches the bug, retries
  4. On success, writes output.json with structured operations
  5. Bridge validates the output and streams back to the add-in
  6. Add-in applies operations to the sheet

License

MIT

About

AI coding agent embedded in Excel — local execution, full agentic loop, plain-English data transforms

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages