How to Run Ollama in Excel With XLlama (Local AI Formulas)
To run Ollama in Excel, install Ollama, download a local model such as gemma3:4b, and add the XLlama add-in to desktop Excel on Windows. XLlama gives you a chat pane and two formulas: XLLAMA.PROMPT for one answer per cell and XLLAMA.EXTRACT for a table. The model runs on your PC, so the data stays there.
Table of contents
How it works
Ollama runs the AI model on your computer and answers on a local address, http://127.0.0.1:11434. XLlama is the Excel side: it reads the cells you point it to, sends them to Ollama as text and writes the answer back into the sheet. No cloud AI service is involved and there is no cost per question.
Ollama cannot open an .xlsx file by itself. That is the gap XLlama fills: the workbook stays open in Excel and the add-in passes the relevant cells to the model. The video above shows the older VBA edition of XLlama, which is retired; everything below is for the current Windows add-in, version 1.2.
Requirements
You need desktop Excel 2016 or newer on 64-bit Windows, the XLlama installer, and Ollama with at least one downloaded model on the same PC. Excel for Mac, Excel on the web, iPad and native ARM64 Excel are not supported.
| Item | Details |
|---|---|
| Excel | Desktop Excel 2016 or newer, 32-bit or 64-bit, on 64-bit Windows |
| XLLAMA.EXTRACT | Excel with dynamic arrays: Microsoft 365 or Excel 2021 and later |
| Runtimes | .NET 10 Windows Desktop Runtime and WebView2. Setup checks both and offers the download. |
| Ollama | Installed and running on the same PC. Remote Ollama servers are not supported. |
| A model | At least one local model, for example gemma3:4b (about 3.3 GB download) or gemma3:1b (about 815 MB) |
| Internet | For the installs and model downloads. The answers themselves are generated offline. |
Set up Ollama and XLlama
Setup is three installs: XLlama, Ollama and one model. XLlama can open the Ollama download and pull the model for you, so you do not need a terminal. Close Excel before you run the XLlama installer.
-
Install XLlama. Request the installer on the XLlama page; it arrives by email. Save your work, close every Excel window and run
XLlama-Setup.exe, then choose Install XLlama. The installer is unsigned, so Windows may warn you: choose More info, then Run anyway. If setup asks for the .NET Desktop Runtime or WebView2, install it and choose Check again. -
Open the pane. Start Excel, open a workbook and choose XLlama > Open XLlama on the ribbon.
-
Install Ollama. In the pane, choose Get Ollama, then Download for Windows, and run the Ollama installer. If Ollama offers an account, choose No thanks, I’ll use Ollama locally. Local models do not need an Ollama account.
-
Download a model. Back in XLlama, choose Manage models, type
gemma3:4band choose Download model. When the download finishes, the model is marked In use. -
Ask a first question. Choose Chat, click into a small table, type Summarize this data in three bullet points and choose Send. Without sample data, Help > Create demo sheet adds a small table and two example formulas.
Ollama’s own commands work as well. XLlama lists every local model that Ollama has installed, however it got there:
ollama pull gemma3:4b
ollama list
ollama rm gemma3:1b
ollama pull downloads a model, ollama list shows the installed models with their exact names, and ollama rm deletes one to free disk space. XLlama has no delete button for models, so ollama rm is the way to remove them. The XLlama getting started guide has a short video of the current setup.
Choose a model
Start with gemma3:4b for everyday text tasks and switch to gemma3:1b if your PC struggles. Larger models handle harder tasks better but need more memory and answer more slowly. Test any model on a few cells before you fill a whole column.
The Ollama model library lists every model you can pull. The tag after the colon, such as 1b, 4b or 8b, is the size in billions of parameters, and the download size is not the same as the memory the model needs while it runs. To switch, open Models and choose Use model next to an installed model. The selection applies to chat and to every formula that does not name its own model.
Reasoning models such as deepseek-r1 and qwen3 work too. In formulas XLlama turns their thinking off, so the cell receives only the answer. In chat, the setting Show reasoning separately when supported (on by default) keeps the reasoning apart from the answer. Ollama’s cloud models are blocked: XLlama only sends data to models that run on your computer.
XLLAMA.PROMPT
XLLAMA.PROMPT sends an instruction plus the cells you reference to the model and returns one plain-text answer in the cell. Use it to classify, summarize, translate, rewrite or pull one value out of a text. Fill it down to work through a list row by row.
=XLLAMA.PROMPT(prompt, context, model)
prompt is the instruction, context is the cell or range the model reads, and model is optional. Leave it out to use the model selected in the pane, or type a name such as "gemma3:1b" to use a different model in this formula.
| Task | Formula |
|---|---|
| Sort support requests | =XLLAMA.PROMPT("Classify this request as Billing, Delivery, Product or Returns. Return only the category.", C7) |
| Review sentiment | =XLLAMA.PROMPT("Is this review positive, neutral or negative? Return one word.", B2) |
| Names in a text | =XLLAMA.PROMPT("List every full name in the text, separated by commas.", A2) |
| Translation | =XLLAMA.PROMPT("Translate this text to German.", A2) |
| Grammar and spelling | =XLLAMA.PROMPT("Correct the spelling and grammar. Return only the corrected text.", A2) |
| Number in words | =XLLAMA.PROMPT("Write this number in English words.", A2) |
| Summary of a range | =XLLAMA.PROMPT("Summarize this feedback in one sentence.", A2:B20) |
A few things make the answers predictable:
- Formulas run at temperature 0 with a fixed seed, so the same input gives the same answer.
- XLlama tells the model to return plain text with no introduction, and to answer
Not foundwhen the answer is not in the data. Filter for that value when you check the results. - While the model works, the cell shows
#GETTING_DATA. You can keep working in Excel; the answer appears by itself. - Answers are cached. A recalculation with unchanged inputs reuses the saved answer instead of asking the model again. For a fresh answer, select the cells and choose Settings > Refresh selected formula answers.
- If your Excel separates arguments with semicolons, use semicolons instead of commas.
Small models still make mistakes. In my support-request demo, a small model filed “The invoice total is wrong” under Returns instead of Billing. Check a sample before you rely on a filled-down column. The PROMPT reference lists every argument and message.
XLLAMA.EXTRACT
XLLAMA.EXTRACT turns free text into a table. You name the columns you want, and the result spills into the cells below and to the right with a header row. One formula can read an email, a notes column or a list of receipts and return one row per record.
=XLLAMA.EXTRACT(prompt, context, fields, model)
fields is a comma-separated list of column names, or a range that holds them, with up to 12 fields. This formula turns the order email in B7 into an order table:
=XLLAMA.EXTRACT("Extract one row per order. Quantity must be a number. Use YYYY-MM-DD for DueDate.", B7, "Customer,Product,Quantity,DueDate")

The same pattern pulls contact details out of messy notes. Ask for exactly the fields you need:
=XLLAMA.EXTRACT("Extract every contact mentioned", A2:A50, "name, email, phone")
Keep the cells below and to the right empty, or Excel shows #SPILL!. One EXTRACT returns at most 500 records. To regenerate a table, select its top-left formula cell, not the spilled results, and choose Settings > Refresh selected formula answers. The EXTRACT reference has the details.
Chat with a sheet
The chat pane answers questions about your workbook without a formula. A chip above the message box decides which cells go with the question: Auto, Selection, Active sheet, Workbook or None. Auto uses your selection, otherwise the table around the cursor, otherwise the whole sheet.
Chat suits one-off questions about a whole table: which product has the highest unit price, which guests on a potluck list still have no dish, or what to cook with the ingredients in a range. Every question also carries the sheet names, table names and column headers, so you can ask what is on the Costs sheet without sending any cells. Hidden and filtered rows are left out unless you include them from the chip menu.

Under each answer you get Copy, Insert in cell, New sheet and Regenerate. When an answer contains an Excel formula, Insert formula lets you check the formula and the destination cell before XLlama writes it. Use that route for totals and counts: small models often get sums over many rows wrong, and an Excel formula does not. Choose what XLlama reads explains the chip in detail.
Settings
Settings is in the menu at the top left of the XLlama pane. Most people only ever change Context size and Keep model loaded. Choose Save settings after a change.
| Setting | What it does |
|---|---|
| System instructions | Standing instructions for the chat, such as a tone or an answer format. Formulas ignore it and use their own fixed instructions. |
| Temperature | Optional, chat only. Formulas always use 0. |
| Keep model loaded | How long Ollama keeps the model in memory after a request: 5 minutes (default), 30 minutes, 2 hours, until Ollama exits, or unload after the request. |
| Show reasoning separately when supported | Keeps a reasoning model’s thinking apart from the chat answer. |
| Selected data format | Table (simple, default) or Cell references, where every value carries its address. Chat only. |
| Max cells per question | Empty means Auto: as many cells as fit. Enter a number to send fewer. |
| Context size | How much data the model reads at once: Auto (16K), 8K, 16K, 32K or 64K. |
| Appearance | Auto (match Windows), Light or Dark. |
| Connection settings | The Ollama address, http://127.0.0.1:11434 by default. Another port on this computer is allowed; remote servers are not. |
Speed and hardware
Speed depends on the model size, the free memory and whether Ollama can use a graphics card. A dedicated GPU is not required, but it helps with larger models and larger Context sizes. The first answer after a pause is slower because Ollama loads the model into memory first.
- Start with gemma3:4b or gemma3:1b and a few cells, then scale up.
- Set Keep model loaded to 30 minutes or 2 hours while you work with one model, so later answers skip the loading step.
- Lower Context size to 8K on a slow PC. Bigger sizes read more data but use more memory and answer more slowly.
- Send less data: in chat, choose Selection instead of Active sheet or Workbook.
- Close other memory-hungry programs.
- Read the line under each chat answer, for example 10 tokens · 67 tok/s · 1.1K of 16K context. It shows how fast the model writes and how much of the context the question used.
The Context size guide explains each size and its messages.
Limits
A local model is much smaller than the cloud models behind Copilot or ChatGPT, so expect more mistakes on reasoning, arithmetic and rare facts. XLlama makes sure the data reaches the model cleanly; it does not make the model smarter. Check a sample before you trust a whole column.
- Free plan: 20 AI responses per month, shared by chat and new formula answers, and five XLlama formula cells per workbook. Cached answers do not count. A whole EXTRACT table counts as one formula cell. Pro removes both limits and adds Convert selection to values.
- Formula input: at most 1,000 input cells per formula and 16,000 characters per prompt. Large jobs work best in batches.
- EXTRACT: up to 12 fields and 500 records per formula.
- Sums and counts: small models are unreliable over many rows and sometimes invent a value instead of answering
Not found. Ask for an Excel formula instead. - Platform: desktop Excel on Windows only, with Ollama on the same PC.
- Internet: needed for model downloads. Pro checks its license daily and keeps working for up to seven days offline after a successful check. These checks do not send prompts or worksheet data.
Local AI vs Copilot
Copilot in Excel and cloud add-ins such as ChatGPT or Claude for Excel send your prompt and the relevant workbook data to the provider’s servers. They run larger models and answer faster, but need a subscription or an API account. XLlama keeps the data on your PC and has no per-question cost, in exchange for smaller models and your own hardware doing the work.
When the data is not sensitive and you want a stronger model in a formula, a cloud API is the other route: my posts on GPT-5 in Excel and DeepSeek in Excel with VBA show that setup. If you would rather call Ollama from your own VBA code, its local API listens on the same port (http://127.0.0.1:11434/api/chat), and the HTTP request and JSON parsing follow the same pattern as the DeepSeek module.
Troubleshooting
Most problems come down to Ollama not running, a model name that does not match, or a request too large for the memory. Start with Help > Diagnostics > Run diagnostics in the pane. It checks the Ollama installation, the connection and the selected model, and Test model response sends a short test without using a Free response.

XLlama: Ollama isn’t running
Open Ollama from the Windows Start menu, wait until it has started, then recalculate (or choose Open Ollama in Diagnostics). To check by hand, open http://127.0.0.1:11434 in a browser. A running Ollama answers with the text Ollama is running.
Port 11434 or a custom address
11434 is Ollama’s default port and XLlama’s default address. If you moved Ollama to another port, for example with the OLLAMA_HOST environment variable, open Connection settings, enter the same local address, choose Test connection and then Save settings. Restore default puts http://127.0.0.1:11434 back. A WSL or Docker setup works as long as its API answers on this computer; the installation check in Diagnostics is only a hint.
Model isn’t downloaded
The message XLlama: model 'name' isn't downloaded. means the name in the formula or the pane does not match an installed model. Run ollama list to see the exact names, such as gemma3:4b, then download the model in Models or with ollama pull. Remember that the formula’s model argument overrides the pane.
Slow first answer or a long #GETTING_DATA
The first request loads the model into memory, which takes a while on a slower PC. Later answers are faster while the model stays loaded. A formula gives up after 10 minutes with XLlama: timed out after 10 minutes. Try a smaller range or a smaller model, then recalculate. The slow answers guide lists more fixes.
Ollama doesn’t have enough memory
Set Context size to 8K, choose a smaller model in Models, or close other large programs, then try again.
XLlama: Excel was busy
Excel cannot hand over data while you edit a cell or a dialog is open. Press Enter or Esc, close the dialog and recalculate. In chat the same problem reads Excel didn’t respond in time.
Free supports five XLlama formula cells per workbook
On Free, the sixth and later XLlama formula cells in a workbook show this message while the first five keep working. One EXTRACT over a range often replaces a filled-down column of PROMPT formulas.
#NAME? in workbooks from the VBA edition
Workbooks built with the old VBA edition call XLlamaPrompt, which the current add-in does not have. Rewrite those cells with XLLAMA.PROMPT, and remove the old add-in before you install the new one.
Model download fails
An error that mentions registry.ollama.ai comes from Ollama’s download server, not from your local connection. Check the internet connection and choose Retry download; Ollama reuses the parts it already has. If ollama pull reports a 412 manifest error, your Ollama version is too old for that model: install the latest version from ollama.com and pull again.
FAQ
Is XLlama free?
Ollama and the open models are free to download. XLlama has a Free plan with 20 AI responses per month and five formula cells per workbook, enough to try it on your own data. Pro removes those limits.
Does it work without internet?
Yes, once Ollama and a model are installed. The answers are generated on your PC. You need internet again only to download another model, to check for updates or, on Pro, for the daily license check.
Resources
- XLlama getting started guide (with setup video)
- XLlama cannot reach Ollama
- XLlama model guide
- Ollama for Windows and the Ollama model library
Ask local Ollama models about your spreadsheet and use them in formulas. Your data stays on your PC.
