← Blog

How to Integrate Claude Into Excel: 3 Working Methods

2026-09-09 · 5 min read · SubToAPI Team

Excel doesn't have a native Claude plugin, so integrating Claude into Excel means connecting the Claude API to a spreadsheet workflow through one of three practical routes: a Python script that reads/writes .xlsx files, an Office Script or VBA macro that calls an HTTP endpoint, or a lightweight API layer that turns your Claude access into standard REST calls you can hit from any of those tools.

This guide walks through each method with working code, so you can pick the one that fits your setup — whether you're processing spreadsheets in bulk, adding an "Ask AI" button inside a workbook, or building a repeatable pipeline for a team.

Method 1: Python + openpyxl (best for batch processing)

If you're processing many rows — summarizing feedback, classifying support tickets, extracting entities from free-text columns — Python is the fastest path. openpyxl or pandas read the sheet, you send each row (or a batch) to Claude, and write the response back into a new column.

import openpyxl
import requests
import os

wb = openpyxl.load_workbook("data.xlsx")
sheet = wb.active

API_KEY = os.environ["SUBTOAPI_KEY"]

def ask_claude(prompt):
    resp = requests.post(
        "https://api.subtoapi.app/v1/messages",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json={
            "model": "claude-sonnet-4",
            "max_tokens": 200,
            "messages": [{"role": "user", "content": prompt}]
        }
    )
    return resp.json()["content"][0]["text"]

for row in sheet.iter_rows(min_row=2, max_col=1):
    cell = row[0]
    if cell.value:
        summary = ask_claude(f"Summarize this feedback in one sentence: {cell.value}")
        sheet.cell(row=cell.row, column=2, value=summary)

wb.save("data_with_summaries.xlsx")

This pattern works whether you're calling the Claude API directly or through a gateway. The advantage of running it through an endpoint like api.subtoapi.app instead of managing raw Claude credentials is that you get a stable sub_live_... API key, usage metadata per request, and the ability to hand the script to a teammate without sharing your underlying access — see the quickstart for the exact request format.

Method 2: Office Scripts (best for in-workbook automation)

If you want Claude available inside Excel — a button that summarizes a selected range or drafts text into a cell — Office Scripts (TypeScript, runs in Excel on the web and desktop with a Microsoft 365 subscription) is the cleanest option. Office Scripts can't call arbitrary URLs directly unless fetch is allowed in your tenant, but where it is, the pattern is:

function main(workbook: ExcelScript.Workbook) {
  const sheet = workbook.getActiveWorksheet();
  const range = sheet.getRange("A2:A10");
  const values = range.getValues();

  values.forEach((row, i) => {
    const text = row[0] as string;
    if (text) {
      fetch("https://api.subtoapi.app/v1/messages", {
        method: "POST",
        headers: {
          "Authorization": "Bearer " + "YOUR_SUBTOAPI_KEY",
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          model: "claude-sonnet-4",
          max_tokens: 150,
          messages: [{ role: "user", content: `Classify sentiment: ${text}` }]
        })
      })
      .then(r => r.json())
      .then(data => {
        sheet.getCell(1 + i, 1).setValue(data.content[0].text);
      });
    }
  });
}

Many corporate tenants restrict outbound fetch calls in Office Scripts for security reasons — check with your admin before building on this. If fetch is blocked, Power Automate is the usual workaround: a flow triggered from Excel that calls the API and writes the result back to the sheet.

Method 3: Power Automate (best for governed environments)

For teams that can't run arbitrary scripts, Power Automate's HTTP connector can call any REST endpoint, including Claude via a gateway. The flow looks like:

  1. Trigger: "For a selected row" or "When a row is created" in an Excel table (via the Excel Online connector).
  2. Action: HTTP POST to https://api.subtoapi.app/v1/messages with your API key in the Authorization header and the row's cell value in the JSON body.
  3. Action: Parse the JSON response and use "Update a row" to write the result back into the same table.

This is slower to build than a Python script but works entirely inside Microsoft's governed connector ecosystem, which matters if IT policy restricts what can touch company data.

Why route through an API gateway instead of raw Claude access

All three methods above need one thing in common: a stable, keyed HTTP endpoint that accepts a prompt and returns text. If you already pay for Claude access, the simplest way to get that endpoint without managing separate API billing is a service like SubToAPI, which turns your existing Claude subscription into a sub_live_... API key you can call from Python, Office Scripts, or Power Automate exactly like the examples above.

That matters for Excel integrations specifically because:

You don't need any of this to get started — a free trial at signup gives you a working key in a couple of minutes, and the Messages API reference has the exact payload shape used in the examples above.

Choosing the right method

In all four cases, the actual Claude call is identical: a POST request with a model name, a max token count, and a messages array. The differences are entirely about where that request originates from and how the response gets written back into a cell.

questions

Does Excel have a built-in Claude add-in? No. Microsoft's Copilot is the native AI assistant in Excel; integrating Claude specifically requires a script, macro, or Power Automate flow that calls the Claude API.

Can I use Claude in Excel without writing code? Power Automate gets close — you configure an HTTP action visually — but you still need to construct the JSON request body manually the first time.

What's the fastest way to test a Claude-to-Excel call before building automation? Run a single curl request against the Messages API from your terminal to confirm your key and payload work, then wrap that same request in Python, Office Scripts, or Power Automate.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →