Loading...
Loading...
Manage Google Sheets spreadsheets. Read/write cell values and ranges, manage sheets, formatting, and formulas. Use when working with Google Sheets spreadsheet management.
npx skill4agent add odyssey4me/agent-skills google-sheetspip install --user google-auth google-auth-oauthlib google-api-python-client keyring pyyamlpython scripts/google-sheets.py check~/.config/agent-skills/google.yamloauth_client:
client_id: your-client-id.apps.googleusercontent.com
client_secret: your-client-secretpython scripts/google-sheets.py check| Scope | Permission | Used For |
|---|---|---|
| Read spreadsheets | Reading cell values and metadata |
| Full access | Creating and modifying spreadsheets |
keyring del agent-skills google-sheets-token-jsonpython scripts/google-sheets.py checkpython scripts/google-sheets.py checkpython scripts/google-sheets.py auth setup \
--client-id YOUR_CLIENT_ID \
--client-secret YOUR_CLIENT_SECRET~/.config/agent-skills/google-sheets.yaml--client-id--client-secretpython scripts/google-sheets.py spreadsheets create --title "My Spreadsheet"--title--sheets--json# Create with default Sheet1
python scripts/google-sheets.py spreadsheets create --title "Sales Data"
# Create with custom sheets
python scripts/google-sheets.py spreadsheets create \
--title "Q1 Report" \
--sheets "Summary,January,February,March"
# Output:
# ✓ Spreadsheet created successfully
# Title: Q1 Report
# Spreadsheet ID: 1abc...xyz
# Sheets: 4 (Summary, January, February, March)
# URL: https://docs.google.com/spreadsheets/d/1abc...xyz/editpython scripts/google-sheets.py spreadsheets get SPREADSHEET_IDspreadsheet_id--jsonpython scripts/google-sheets.py spreadsheets get 1abc...xyz
# Output:
# Title: Sales Data
# Spreadsheet ID: 1abc...xyz
# Sheets: 2 (Sheet1, Summary)
# URL: https://docs.google.com/spreadsheets/d/1abc...xyz/editpython scripts/google-sheets.py values read SPREADSHEET_ID --range "Sheet1!A1:D5"spreadsheet_id--range--format--json# Read a range
python scripts/google-sheets.py values read 1abc...xyz --range "Sheet1!A1:C3"
# Output (formatted as table):
# Name | Age | City
# Alice | 30 | NYC
# Bob | 25 | LA
# Read formulas
python scripts/google-sheets.py values read 1abc...xyz \
--range "Sheet1!D1:D10" \
--format FORMULApython scripts/google-sheets.py values write SPREADSHEET_ID \
--range "Sheet1!A1" \
--values '[[\"Name\",\"Age\"],[\"Alice\",30]]'spreadsheet_id--range--values--json# Write data starting at A1
python scripts/google-sheets.py values write 1abc...xyz \
--range "Sheet1!A1" \
--values '[[\"Product\",\"Price\",\"Quantity\"],[\"Widget\",9.99,100]]'
# Write a single row
python scripts/google-sheets.py values write 1abc...xyz \
--range "Sheet1!A5" \
--values '[[\"Total\",999,50]]'
# Output:
# ✓ Values written successfully
# Updated cells: 6
# Updated range: Sheet1!A1:C2=python scripts/google-sheets.py values append SPREADSHEET_ID \
--range "Sheet1" \
--values '[[\"New\",\"Row\",\"Data\"]]'spreadsheet_id--range--values--json# Append a single row
python scripts/google-sheets.py values append 1abc...xyz \
--range "Sheet1" \
--values '[[\"Charlie\",35,\"Chicago\"]]'
# Append multiple rows
python scripts/google-sheets.py values append 1abc...xyz \
--range "Sheet1" \
--values '[[\"David\",28,\"Boston\"],[\"Eve\",32,\"Seattle\"]]'
# Output:
# ✓ Values appended successfully
# Updated cells: 3
# Updated range: Sheet1!A4:C4python scripts/google-sheets.py values clear SPREADSHEET_ID --range "Sheet1!A1:D10"spreadsheet_id--range--json# Clear a range
python scripts/google-sheets.py values clear 1abc...xyz --range "Sheet1!A1:Z100"
# Output:
# ✓ Values cleared successfully
# Cleared range: Sheet1!A1:Z100python scripts/google-sheets.py sheets create SPREADSHEET_ID --title "New Sheet"spreadsheet_id--title--jsonpython scripts/google-sheets.py sheets create 1abc...xyz --title "Q2 Data"
# Output:
# ✓ Sheet created successfully
# Title: Q2 Data
# Sheet ID: 123456789python scripts/google-sheets.py sheets delete SPREADSHEET_ID --sheet-id 123456789spreadsheet_id--sheet-id--json# Get sheet IDs first
python scripts/google-sheets.py spreadsheets get 1abc...xyz --json | jq '.sheets[].properties | {title, sheetId}'
# Delete a sheet
python scripts/google-sheets.py sheets delete 1abc...xyz --sheet-id 123456789
# Output:
# ✓ Sheet deleted successfully# Create spreadsheet
SS_ID=$(python scripts/google-sheets.py spreadsheets create \
--title "Employee Data" --json | jq -r '.spreadsheetId')
# Write headers
python scripts/google-sheets.py values write $SS_ID \
--range "Sheet1!A1" \
--values '[["Name","Department","Salary","Start Date"]]'
# Append employee records
python scripts/google-sheets.py values append $SS_ID \
--range "Sheet1" \
--values '[["Alice","Engineering",120000,"2023-01-15"],["Bob","Sales",95000,"2023-03-01"]]'
# Add a summary sheet
python scripts/google-sheets.py sheets create $SS_ID --title "Summary"
# Read the data
python scripts/google-sheets.py values read $SS_ID --range "Sheet1!A1:D10"# Write data with formulas
python scripts/google-sheets.py values write $SS_ID \
--range "Sheet1!A1" \
--values '[["Item","Price","Qty","Total"],["Widget",10,5,"=B2*C2"],["Gadget",20,3,"=B3*C3"]]'
# Read formulas
python scripts/google-sheets.py values read $SS_ID \
--range "Sheet1!D2:D3" \
--format FORMULA
# Read calculated values
python scripts/google-sheets.py values read $SS_ID \
--range "Sheet1!D2:D3" \
--format FORMATTED_VALUE#!/bin/bash
SS_ID="your-spreadsheet-id"
# Clear old data
python scripts/google-sheets.py values clear $SS_ID --range "Sheet1!A1:Z1000"
# Write new data in batches
python scripts/google-sheets.py values write $SS_ID \
--range "Sheet1!A1" \
--values '[["Date","Revenue","Expenses","Profit"]]'
for month in Jan Feb Mar; do
python scripts/google-sheets.py values append $SS_ID \
--range "Sheet1" \
--values "[[\"\$month\",10000,7000,\"=B${ROW}-C${ROW}\"]]"
donekeyring del agent-skills google-sheets-token-jsonpython scripts/google-sheets.py checkhttps://docs.google.com/spreadsheets/d/1abc...xyz/edit1abc...xyzSheet1!A1:D5'My Sheet'!A1:B2# Correct
--values '[["Hello","World"]]'
--values "[[\"Name\",\"Age\"]]"
# Incorrect
--values [[Hello,World]] # Missing quotessheets createsheets deletespreadsheets get --jsonpip install --user google-auth google-auth-oauthlib google-api-python-client keyring pyyamlsheets.googleapis.com