How to work with Google Sheets and Excel with an AI agent
For Excel files, let the agent edit them in your project with Python and openpyxl. For Google Sheets, use the Google Workspace CLI (gws) and its Sheets skill, or connect Grok Bot to Google Sheets. Always have the agent write to a copy first and check formulas before replacing the real file.
Checked against official docs on Oct 26, 2026.
Get the free starter kit. One short email a day when our setups change.
Free starter kit on signup: 2 Claude Code skills and 1 agent persona from our paid packs. By subscribing you agree to get The AI Loadout Daily, one email each morning. No spam, we never sell your email, and every email has a one-click unsubscribe link.
Claude Code
Excel: put the .xlsx in your project and ask: "Use Python and openpyxl to add a monthly totals tab. Save as a new file."Google Sheets: npm install -g @googleworkspace/cli, gws auth setup, gws auth login -s sheetsCopy the gws sheets skill into .claude/skills/ so Claude knows the commands
Codex
Same gws setup, with the skill in .agents/skills/Ask Codex to read or update a sheet and show you the change first
Cursor
Same gws setup, with the skill in .agents/skills/ or .cursor/skills/For Excel, ask the agent for a Python script you can rerun
Grok Bot
Connect Google Sheets to Grok BotAsk it to read, clean or chart the dataFor Excel, send the file and get an edited copy back
Gotchas
- Agents sometimes write values where you need formulas. Ask for formulas.
- Back up before bulk edits.
- gws is not an official Google product, per its README.
The loadout for this job
- Tools: ChatGPT, Claude
- Repo: Anthropic Agent Skills
- Model: GPT-6.1 Sol
- Bot: Grok Bot
- Full setup: Best AI for Excel and Google Sheets
FAQ
Can an AI agent edit Google Sheets?
Yes, through the Google Workspace CLI, a connector, or the Sheets API.
Can Claude Code edit Excel files?
Yes, by writing and running Python with openpyxl on the file.
Related how-tos
Sources
Commands change. Check the linked docs before you run anything. All how-to guides