AgentSkillsCN

google-sheets

使用 gspread 与服务账号凭据,读写 Google Sheets 中的数据。默认电子表格:Jona 的 OpenClaw Sheets。

SKILL.md
--- frontmatter
name: google-sheets
version: 1.1.0
description: Read and write data to Google Sheets using gspread and Service Account credentials. Default spreadsheet: Jona's OpenClaw Sheets.
metadata: {"category":"productivity","emoji":"📊"}

Google Sheets Skill

Write and read data from Google Sheets using gspread library.

Default Spreadsheet

Spreadsheet ID: 1r_Q1S-zF8meqYVGkAv30dtI4_qePbDesSh5HCeuYcf0 URL: https://docs.google.com/spreadsheets/d/1r_Q1S-zF8meqYVGkAv30dtI4_qePbDesSh5HCeuYcf0/edit

Esta es la spreadsheet principal usada por Clawd para tareas de Jona. Usa este spreadsheet_id como default en todas las operaciones salvo que se indique lo contrario.

Setup

Prerequisites

  1. Create a Google Cloud project
  2. Enable Google Sheets API
  3. Create a Service Account and download credentials JSON
  4. Share your spreadsheet with the service account email

Credentials

Store credentials at: ~/.config/google/credentials.json

json
{
  "type": "service_account",
  "project_id": "your-project-id",
  "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
  "client_email": "your-sa@project.iam.gserviceaccount.com",
  ...
}

Usage

Write Data

python
from google-sheets import write_to_sheet

# Usando spreadsheet default
write_to_sheet(
    sheet_name="Sheet1",
    data=[["Header1", "Header2"], ["Value1", "Value2"]]
)

# Con spreadsheet específico
write_to_sheet(
    spreadsheet_id="other-sheet-id",
    sheet_name="Sheet1",
    data=[["Header1", "Header2"], ["Value1", "Value2"]]
)

Read Data

python
from google-sheets import read_from_sheet

# Usando spreadsheet default
data = read_from_sheet(
    sheet_name="Sheet1",
    range="A1:B10"
)

Create New Sheet

python
from google-sheets import create_sheet

create_sheet(
    title="NewSheetName",
    rows=100,
    cols=26
)

API

write_to_sheet(spreadsheet_id, sheet_name, data)

Write a 2D list of data to the specified range.

read_from_sheet(spreadsheet_id, sheet_name, range="A1:Z100")

Read data from specified range.

create_sheet(spreadsheet_id, title, rows=100, cols=26)

Create a new worksheet.

list_sheets(spreadsheet_id)

List all worksheets in a spreadsheet.