An open-source, multi-model AI sidebar add-in for Microsoft Excel β powered by Pi.
Bring your own key. Free. Open source.
Pi for Excel puts an AI assistant directly in your Excel sidebar. It can read your spreadsheet, write formulas, format cells, search data, and trace dependencies β all through natural conversation.
Unlike proprietary alternatives, Pi for Excel:
- Works with any LLM β Anthropic, OpenAI, Google, local models via Ollama/vLLM
- Keeps your data local β the agent runs entirely in the browser; your spreadsheet data never leaves your machine (only the context you send to your chosen LLM provider)
- Is free and open source β no subscription, no per-seat pricing
Existing AI add-ins for Excel are closed-source, locked to a single model, and charge $20+/month. They also leave real capabilities on the table:
| Proprietary add-ins | Pi for Excel | |
|---|---|---|
| Context awareness | Thin metadata push (sheet names + dimensions). Agent has to make tool calls just to see what you're looking at. | Rich workbook blueprint (headers, named ranges, tables, formula density) + auto-read of your selection β the agent already knows what you're looking at before you ask. |
| Formula tracing | Manual cell-by-cell tracing. Deep dependency trees take dozens of tool calls. | trace_dependencies β full formula tree in a single call via Office.js getDirectPrecedents(). |
| Sessions | Total amnesia. Close the sidebar, lose everything. | Persistent sessions saved to IndexedDB. Resume any conversation, even after restarting Excel. |
| Change tracking | No awareness of what you edited between messages. | Automatic change tracking β the agent sees your edits and adapts. |
| Models | Locked to one provider and model. | Any model β swap between Opus, Sonnet, GPT, Gemini, Codex, or local models mid-conversation. |
| Cost | $20+/month per seat. | Free. Bring your own API key. |
| Tool overhead | Separate tools for compact vs. detailed reads β the model often picks the wrong one. | 11 tools, one per verb. read_range has a mode param (compact/csv/detailed). Less overhead, fewer wasted calls. |
| Writes | Overwrite protection, but no verification. | Auto-verification β reads back written cells to check for #REF!, #VALUE!, and other errors. |
- 11 Excel tools β
get_workbook_overview,read_range,write_cells,fill_formula,search_workbook,modify_structure,format_cells,conditional_format,comments,trace_dependencies,view_settings - Composable cell styles β named format presets (
"currency","percent","integer") and structural styles ("header","total-row","input") that compose like CSS classes:style: ["currency", "total-row"] - Auto-context injection β automatically reads around your selection and tracks changes between messages
- Workbook blueprint β sends a structural overview of your workbook to the LLM at session start (auto-invalidates after structural changes)
- Multi-provider auth β API keys, OAuth (Anthropic, OpenAI, Google, GitHub Copilot, Antigravity), or reuse credentials from Pi TUI
- Persistent sessions β conversations auto-save to IndexedDB and survive sidebar close/reopen. Resume any previous session with
/resume - Write verification β automatically checks formula results after writing
- Clickable cell references β cell addresses in assistant messages navigate to the range with a highlight glow
- Markdown tool cards β tool outputs render as formatted markdown (tables, lists, headers) instead of raw text
- Slash commands β type
/to browse all available commands with fuzzy search - Extensions β modular extension system with slash commands and inline widget UI (e.g.,
/snake) - Keyboard shortcuts β
Escapeto interrupt,Shift+Tabto cycle thinking depth (incl. max /xhigheffort on Opus 4.6+),Ctrl+Oto hide/show thinking + tool details - Working indicator β rotating whimsical messages and feature discovery hints while the model is streaming
- Pi-compatible messages β conversations use the same
AgentMessageformat as Pi TUI. Session storage differs (IndexedDB vs JSONL), but the message layer is shared β future import/export is straightforward.
See docs/install.md.
- Node.js 20+
- Microsoft Excel (desktop, macOS or Windows)
- mkcert for local HTTPS
git clone https://github.com/tmustier/pi-for-excel.git
cd pi-for-excel
# Install dependencies
npm install
# Generate HTTPS certificates (required by Office add-ins)
mkcert -install # one-time: trust the CA
mkcert localhost
mv localhost.pem cert.pem
mv localhost-key.pem key.pem
# Start dev server
npm run devmacOS:
cp manifest.xml ~/Library/Containers/com.microsoft.Excel/Data/Documents/wef/Then open Excel β Insert β My Add-ins β Pi for Excel (Dev).
Windows:
npm run sideloadOn first launch, a welcome overlay appears with provider login options:
- OAuth β click a provider (e.g. Anthropic) to authenticate in your browser, then paste the authorization code back into the add-in when prompted.
- API key β paste a key directly for any supported provider.
- Pi TUI credentials β if you already use Pi TUI, credentials from
~/.pi/agent/auth.jsonare loaded automatically in dev mode.
You can change providers later with the /login command or by clicking the model name in the status bar.
Type / in the message input to see all commands:
| Command | Description |
|---|---|
/new |
Start a new chat session (current session is saved) |
/resume |
Resume a previous session |
/name <title> |
Rename the current session |
/model |
Switch LLM model |
/default-models |
Default model presets (currently opens the model selector) |
/login |
Add or change API keys / OAuth |
/settings |
Open settings dialog |
/shortcuts |
Show keyboard shortcuts |
/compact |
Summarize conversation to free context |
/copy |
Copy last response to clipboard |
/export |
Export conversation |
/share-session |
Share the current session |
/snake |
Play Snake! π (extension) |
| Shortcut | Action |
|---|---|
Escape |
Interrupt the current response |
Shift+Tab |
Cycle thinking depth (off β low β β¦ β max on supported models) |
Ctrl+O |
Toggle collapse of thinking blocks and tool messages |
/ |
Open the slash command menu |
src/
βββ taskpane.ts # Thin entrypoint (boot import + tool renderers + bootstrap)
βββ boot.ts # CSS imports + Lit compat patch install
βββ compat/ # Runtime monkey patches / shims
β βββ lit-class-field-shadowing.ts
β βββ model-selector-patch.ts
βββ taskpane/ # Taskpane wiring modules
β βββ bootstrap.ts # Office.onReady + fallback, styles, global patches
β βββ init.ts # Agent + sidebar wiring
β βββ sessions.ts # IndexedDB session persistence
β βββ queue-display.ts # Steering/follow-up queue UI
β βββ keyboard-shortcuts.ts
β βββ status-bar.ts
β βββ welcome-login.ts
β βββ default-model.ts
β βββ context-injection.ts
βββ excel/helpers.ts # Office.js wrappers + edge-case guards
βββ auth/ # CORS proxy, credential restore, provider mapping
βββ tools/ # Excel tools (read, write, search, format, comments, etc.)
βββ conventions/ # Composable cell styles, format presets, style resolver
βββ context/ # Blueprint, selection auto-read, change tracker
βββ prompt/system-prompt.ts # Model-agnostic system prompt builder
βββ commands/ # Slash command registry + extensions
β βββ types.ts # Command registry + types
β βββ command-menu.ts # Slash menu rendering
β βββ builtins.ts # Public shim
β βββ builtins/ # Builtins split by domain (model/settings/session/export/etc.)
β βββ extension-api.ts # Extension API (overlay, widget, toast, events)
βββ extensions/ # Extension modules
β βββ snake.ts # Snake game (inline widget)
βββ ui/ # Sidebar UI components (Lit + CSS)
β βββ pi-sidebar.ts
β βββ pi-input.ts
β βββ working-indicator.ts
β βββ tool-renderers.ts # Render Excel tool output as markdown + collapsible sections
β βββ theme.css
β βββ provider-login.ts
β βββ toast.ts
β βββ loading.ts
βββ utils/ # small shared helpers (content/type guards/errors/format)
The agent loop runs client-side in Excel's webview (WebView2 on Windows, WKWebView on Mac). Tool calls execute locally via Office.js β no server round-trips for Excel operations.
# Type-check
npx tsc --noEmit
# Build for production
npx vite build
# Validate manifest
npx office-addin-manifest validate manifest.xmlDev: the Vite dev server proxies API + OAuth calls to providers (/api-proxy/*, /oauth-proxy/*).
Production: some OAuth/token endpoints are blocked by browser CORS in Office webviews. Pi for Excel supports a user-configurable CORS proxy:
-
Start the local proxy (recommended: HTTPS):
npm run proxy:https
(defaults to
https://localhost:3001)Security: the proxy only accepts browser requests from Pi for Excel origins by default:
https://localhost:3000(dev)https://pi-for-excel.vercel.app(hosted)
If you host the add-in on a different origin, set
ALLOWED_ORIGINS(comma-separated):ALLOWED_ORIGINS="https://my-addin.example.com" npm run proxy:httpsBy default, the proxy also blocks loopback target URLs (e.g.
http://localhost:11434) to reduce SSRF impact. If you intentionally need to proxy to a local service, set:ALLOW_LOOPBACK_TARGETS=1 npm run proxy:https
If port 3001 is taken, pick another port:
PORT=3003 npm run proxy:https
-
In Excel, run
/settingsβ Proxy tab β enable Use CORS Proxy β set Proxy URL (e.g.https://localhost:3003).
macOS note: the taskpane runs on HTTPS. WKWebView often blocks calling an HTTP proxy from an HTTPS add-in (mixed content). Use npm run proxy:https and a proxy URL like https://localhost:<port>.
Also: our mkcert cert is for localhost by default β https://127.0.0.1:<port> will fail unless you generate a cert that includes 127.0.0.1.
API-key based providers often work without a proxy; OAuth-based logins typically require one.
- 13 Excel tools (read, write, search, format, trace, structure)
- Auto-context injection (workbook blueprint, selection auto-read, change tracking)
- Multi-provider auth (OAuth + API keys for Anthropic, OpenAI, Google, GitHub Copilot, Antigravity)
- Persistent sessions with auto-save and
/resume - Write verification (auto-reads back, checks for errors)
- Custom sidebar UI (Lit components, light theme, frosted glass)
- Slash command system with fuzzy search
- Extension system with widget API
- Keyboard shortcuts (Escape, Shift+Tab, Ctrl+O)
- Maintainability refactor β modularized taskpane + slash command builtins
- Tool consolidation: 14 β 10 tools β one tool per distinct verb, no overlap (#14 Β§A, Β§6)
-
view_settingstool β gridlines, headings, freeze panes, tab color -
read_rangegainsmode: "csv"(absorbsget_range_as_csv) -
get_workbook_overviewgainssheetparam for sheet-level detail (absorbsget_all_objects, closes #8) -
search_workbookgainscontext_rowsfor surrounding data (closes #7) - Compact collapsible tool cards with action verbs + markdown rendering
- Consecutive same-tool grouping with expand/collapse
- Full ESLint upgrade β type-aware
recommendedTypeCheckedpreset, 0 errors/warnings - Architecture: modularized taskpane into 8 focused modules, builtins split by domain
- Composable cell styles β 6 format presets + 5 structural styles, CSS-like composition (#1)
-
commentstool β read, add, update, reply, delete, resolve/reopen cell comments (#2) -
read_rangedetailed mode surfaces comments within range -
format_cellsgainsstyle,number_format_dp,currency_symbol,border_color, individual border edges - Markdown rendering in tool output cards (#15)
- Clickable cell references β navigate to range with highlight glow (#6 partial)
- Revised welcome copy + expandable hint prompts (#11)
- Humanized tool card inputs/outputs (color names, format labels)
- Blueprint invalidation after structural changes
- UI polish: queue layout, thinking/tool card styling, case-insensitive model search
- New tools: charts, tables, data validation (#18)
- Progressive disclosure (#18) β on-demand tool injection as tool count grows
- Conventions Phase 2 (#1) β user-configurable via settings UI, workbook-scoped
- Native Excel styles vs. custom style system (#19)
- Auto-compaction (#20) β context window budget management for long conversations
- Change approval UI (#6) β structured approval flow for overwrites
- Header bar UX (#12) β session switcher, workbook indicator
- Extension API build-out (#13) β dynamic loading, tool registration, sandboxing
- Production CORS solution (#4) β service worker or hosted relay
- Distribution: non-technical install (#16) β hosted build + production manifest
- Tmux tool via local bridge (#3) β terminal access from the add-in
- Python code execution via Pyodide
- SpreadsheetBench evaluation (target >43%)
- Per-workbook instructions (like AGENTS.md)
- On-demand tier 2 tools: named ranges, protection, page layout, images, hyperlinks
- Pivot tables and slicers
- Pi TUI β Excel session import/export
- Pi by @badlogic (Mario Zechner) β the agent framework powering this project (source: https://github.com/badlogic/pi-mono). Pi for Excel uses pi-agent-core, pi-ai, and pi-web-ui for the agent loop, LLM abstraction, and session storage.
- whimsical.ts by @mitsuhiko (Armin Ronacher) β the rotating "Workingβ¦" messages are adapted from his Pi extension, rewritten for a spreadsheet/finance audience.
- Microsoft Copilot Agent Mode β JS code gen + reflection, 57.2% SpreadsheetBench
- Univer β Canvas-based spreadsheet runtime, 68.86% SpreadsheetBench (different architecture)
MIT