How To Build Your Own AI Excel Agent
You’ve Seen the AI Excel Agents. Here’s How to Build Your Own
You’ve probably seen them popping up in your feed: impressive demos of AI agents manipulating spreadsheets, creating charts, and performing complex financial analysis from a single text prompt. It looks like magic, a glimpse into a future where tedious data entry is a thing of the past. Let’s demystify the magic by building our own version of this powerful tool from scratch.
This isn’t just about adding another AI plugin to Excel. This is about understanding the engine behind these agents and building a fully-featured, web-based spreadsheet application that you control, powered by the AI model of your choice. In this article, we’ll walk through the architecture and the core concepts needed to bring your own AI Excel Agent to life.
If you give 10 minutes of your time, you can also have your own cool AI Excel Agent in no time. See video demo below.
The Anatomy of an AI Spreadsheet Agent
Before we dive in, let’s break down our application into its core components. The below lays out the general architecture:
- The Digital Workspace (Frontend): This is the familiar, interactive grid that the user sees and interacts with. It needs to look and feel like a real spreadsheet. For this, we use a powerful library called Handsontable, which gives us that classic Excel-like experience right in the browser.
- The Calculator (Formula Engine): A spreadsheet isn’t just a grid; it’s a powerful calculator. To handle all the complex formulas a user might throw at it — from a simple
=SUM(A1:A10)to nestedIFstatements—we rely on HyperFormula. It acts as the mathematical brain, ensuring all calculations are instant and accurate. - The Central Hub (Backend Server): This is the application’s nervous system, built with Node.js and Express. It runs behind the scenes, managing the spreadsheet’s data, handling user requests, and, most importantly, communicating with our AI.
- The AI Analyst (The Agent Core): This is where the intelligence lies. Our application is designed to be flexible, allowing the user to choose their analyst. We can plug into a powerful AI model like Google’s Gemini 2.5 Pro for maximum capability, or a locally-run open-source model via Ollama for privacy and offline use.
Building the Digital Workspace
The first step is creating an environment where our agent can work. This means building the frontend. We start with a simple HTML page and embed the Handsontable grid, configuring it to stretch across the full screen to create an immersive, Excel-like canvas.
We don’t stop there. A modern spreadsheet needs a modern interface. We build an Excel-style ribbon menu with familiar tabs like “Home” and “Data.” This ribbon isn’t just for show; it houses all the user-facing controls: buttons for adding and deleting sheets, formatting cells as currency or percentages, and crucially, the controls for importing data from PDF or XLSX files. This workspace is the bridge between the human user and the AI agent. You can expand this further to look-like a fully functioning Excel grid.
Wiring Up the Brain: Integrating the AI
With the workspace ready, it’s time to give it a mind. This is where the backend server comes in. When a user types a command like a question from the Financial Modeling World Cup into the agent command box, the frontend doesn’t try to figure it out. Instead, it sends that command, along with a compact summary of the current spreadsheet, to our backend server.
This summary is key. We don’t send the entire file; that would be slow and inefficient. However, I will share the full github repo and you are free to make tweaks and edits as to what works best for your use-case.
The backend then takes this package of information — the user’s goal and the data context — and prepares it for the AI model.
The Agent’s Playbook: Prompting for Action
This is the secret sauce. How do you turn a creative, conversational AI into a precise, reliable spreadsheet operator? You give it a strict set of rules and tools.
Get Arsalan Pardesi’s stories in your inbox
Join Medium for free to get updates from this writer.
We craft a special “system prompt” that acts as the agent’s unbreakable playbook. This prompt tells the AI three things:
- Your Role: “You are an AI spreadsheet operator.”
- Your Tools: “You can only perform these specific actions:
createSheet,setValues,setFormulas, andformatRange." - Your Language: “You MUST respond ONLY with a JSON object that follows this exact structure:
{"steps": [...]}."
By forcing the AI to respond in a structured JSON format, we transform its linguistic output into a machine-readable plan. It can no longer just talk about what it wants to do; it has to provide a step-by-step, executable list of actions.
From Language to Action: A Walkthrough
Let’s see the entire system in action with a real-world example and our tool solving some Financial Modeling World Cup questions.
Other features
Other features included in the application comprise:
- PDF Ingestion: Users can upload a 10-K PDF, which the server processes to extract financial statements (Income, Balance Sheet, Cash Flow).
- XLSX Ingestion: User can open Excel xlsx files.
- AI-Powered Parsing: Utilizes a local LLM via Ollama (qwen3:32b by default) to parse raw text from the PDF into structured JSON data and also has Gemini which can be called using your own API key.
- Agentic Analysis: A conversational agent that accepts natural language goals (e.g., “calculate gross margin %”) and translates them into a sequence of precise, executable spreadsheet operations.
- Streaming & Debugging: The agent’s thought process, from context analysis to final plan, is streamed live to a debug panel in the UI, providing transparency.
- Auditable & Reversible Actions: Every change to the workbook is logged as an atomic, reversible SheetOp, complete with an “undo” history.
- Data Provenance: Tracks the origin of data, allowing users to click a cell and see which document it was derived from.
- XLSX Export: The entire workbook can be exported as a standard .xlsx file.
Conclusion and next-steps
What we’ve built here is more than just a tool; it’s a framework. It demystifies the idea of an “AI agent” and breaks it down into understandable, buildable components. By combining a powerful frontend grid, a robust formula engine, a flexible backend, and the structured intelligence of a large language model, you can create an application that automates complex tasks in a way that feels intuitive and powerful.
I will be adding an agentic workflow to the repository soon. If you would like to contribute to this project, please reach out to me. The github repo can be accessed here (link to repo).
A Message from AI Mind
Thanks for being a part of our community! Before you go:
- 👏 Clap for the story and follow the author 👉
- 📰 View more content in the AI Mind Publication
- 🧠 Improve your AI prompts effortlessly and FREE
- 🧰 Discover Intuitive AI Tools









