google-sheets by vm0-ai/vm0-skills
npx skills add https://github.com/vm0-ai/vm0-skills --skill google-sheets通过直接的 curl 调用使用 Google Sheets API 来读取、写入和管理电子表格数据。
官方文档:
https://developers.google.com/sheets/api
在以下情况下使用此技能:
占位符说明:
{花括号}中的值,如{spreadsheet-id},是占位符。执行时请将其替换为实际值。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
重要提示: 在范围表示法中,工作表名称分隔符 ! 在 URL 路径中必须进行 URL 编码为 %21。例如,Sheet1!A1:D10 变为 Sheet1%21A1:D10。以下所有示例均使用此编码。
基础 URL:https://sheets.googleapis.com/v4/spreadsheets
查找您的电子表格 ID: 电子表格 ID 在 URL 中:https://docs.google.com/spreadsheets/d/{SPREADSHEET_ID}/edit
获取电子表格的信息(工作表、属性):
curl -s "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" | jq '{title: .properties.title, sheets: [.sheets[].properties | {sheetId, title}]}'
读取一个范围的单元格:
curl -s "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1%21A1:D10" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" | jq '.values'
读取工作表中的所有数据:
curl -s "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" | jq '.values'
更新一个范围的单元格。
写入 /tmp/gsheets_request.json:
{
"values": [
["Name", "Email", "Status"]
]
}
然后运行:
curl -s -X PUT "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1%21A1:C1?valueInputOption=USER_ENTERED" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '.updatedCells'
valueInputOption 选项:
RAW:值按原样存储USER_ENTERED:值按用户输入的方式解析(公式会被计算)在工作表末尾添加新行。
写入 /tmp/gsheets_request.json:
{
"values": [
["John Doe", "john@example.com", "Active"]
]
}
然后运行:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1%21A:C:append?valueInputOption=USER_ENTERED&insertDataOption=INSERT_ROWS" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '.updates | {updatedRange, updatedRows}'
在一次请求中读取多个范围:
curl -s "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values:batchGet?ranges=Sheet1%21A1:B5&ranges=Sheet1%21D1:E5" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" | jq '.valueRanges'
在一次请求中更新多个范围。
写入 /tmp/gsheets_request.json:
{
"valueInputOption": "USER_ENTERED",
"data": [
{
"range": "Sheet1!A1",
"values": [["Header 1"]]
},
{
"range": "Sheet1!B1",
"values": [["Header 2"]]
}
]
}
然后运行:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values:batchUpdate" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '.totalUpdatedCells'
清除一个范围的单元格。
写入 /tmp/gsheets_request.json:
{}
然后运行:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1%21A2:C100:clear" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '.clearedRange'
写入 /tmp/gsheets_request.json:
{
"properties": {
"title": "My New Spreadsheet"
},
"sheets": [
{
"properties": {
"title": "Data"
}
}
]
}
然后运行:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '{spreadsheetId, spreadsheetUrl}'
向现有电子表格添加新工作表。
写入 /tmp/gsheets_request.json:
{
"requests": [
{
"addSheet": {
"properties": {
"title": "New Sheet"
}
}
}
]
}
然后运行:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}:batchUpdate" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '.replies[0].addSheet.properties'
从电子表格中删除一个工作表(使用元数据中的 sheetId)。
写入 /tmp/gsheets_request.json:
{
"requests": [
{
"deleteSheet": {
"sheetId": 123456789
}
}
]
}
然后运行:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}:batchUpdate" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json
查找包含特定文本的单元格(读取所有数据然后过滤):
curl -s "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" | jq '[.values[] | select(.[0] | ascii_downcase | contains("search_term"))]'
| 表示法 | 描述 |
|---|---|
Sheet1!A1 | Sheet1 中的单个单元格 A1 |
Sheet1!A1:B2 | 从 A1 到 B2 的范围 |
Sheet1!A:A | 整个 A 列 |
Sheet1!1:1 | 整个第 1 行 |
Sheet1!A1:C | 从 A1 到 C 列末尾 |
'Sheet Name'!A1 | 包含空格的工作表名称需要引号 |
USER_ENTERED,对于字面字符串使用 RAW%21(例如,Sheet1%21A1:D10)每周安装量
275
代码仓库
GitHub 星标数
48
首次出现
2026 年 1 月 24 日
安全审计
安装于
codex251
opencode249
gemini-cli245
github-copilot233
claude-code205
cursor203
Use the Google Sheets API via direct curl calls to read, write, and manage spreadsheet data.
Official docs:
https://developers.google.com/sheets/api
Use this skill when you need to:
Placeholders: Values in
{curly-braces}like{spreadsheet-id}are placeholders. Replace them with actual values when executing.
Important: In range notation, the sheet-name separator
!must be URL encoded as%21in the URL path. For example,Sheet1!A1:D10becomesSheet1%21A1:D10. All examples below use this encoding.
Base URL: https://sheets.googleapis.com/v4/spreadsheets
Finding your Spreadsheet ID: The spreadsheet ID is in the URL: https://docs.google.com/spreadsheets/d/{SPREADSHEET_ID}/edit
Get information about a spreadsheet (sheets, properties):
curl -s "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" | jq '{title: .properties.title, sheets: [.sheets[].properties | {sheetId, title}]}'
Read a range of cells:
curl -s "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1%21A1:D10" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" | jq '.values'
Read all data from a sheet:
curl -s "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" | jq '.values'
Update a range of cells.
Write to /tmp/gsheets_request.json:
{
"values": [
["Name", "Email", "Status"]
]
}
Then run:
curl -s -X PUT "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1%21A1:C1?valueInputOption=USER_ENTERED" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '.updatedCells'
valueInputOption:
RAW: Values are stored as-isUSER_ENTERED: Values are parsed as if typed by user (formulas evaluated)Add new rows to the end of a sheet.
Write to /tmp/gsheets_request.json:
{
"values": [
["John Doe", "john@example.com", "Active"]
]
}
Then run:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1%21A:C:append?valueInputOption=USER_ENTERED&insertDataOption=INSERT_ROWS" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '.updates | {updatedRange, updatedRows}'
Read multiple ranges in one request:
curl -s "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values:batchGet?ranges=Sheet1%21A1:B5&ranges=Sheet1%21D1:E5" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" | jq '.valueRanges'
Update multiple ranges in one request.
Write to /tmp/gsheets_request.json:
{
"valueInputOption": "USER_ENTERED",
"data": [
{
"range": "Sheet1!A1",
"values": [["Header 1"]]
},
{
"range": "Sheet1!B1",
"values": [["Header 2"]]
}
]
}
Then run:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values:batchUpdate" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '.totalUpdatedCells'
Clear a range of cells.
Write to /tmp/gsheets_request.json:
{}
Then run:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1%21A2:C100:clear" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '.clearedRange'
Write to /tmp/gsheets_request.json:
{
"properties": {
"title": "My New Spreadsheet"
},
"sheets": [
{
"properties": {
"title": "Data"
}
}
]
}
Then run:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '{spreadsheetId, spreadsheetUrl}'
Add a new sheet to an existing spreadsheet.
Write to /tmp/gsheets_request.json:
{
"requests": [
{
"addSheet": {
"properties": {
"title": "New Sheet"
}
}
}
]
}
Then run:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}:batchUpdate" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json | jq '.replies[0].addSheet.properties'
Delete a sheet from a spreadsheet (use sheetId from metadata).
Write to /tmp/gsheets_request.json:
{
"requests": [
{
"deleteSheet": {
"sheetId": 123456789
}
}
]
}
Then run:
curl -s -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}:batchUpdate" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" --header "Content-Type: application/json" -d @/tmp/gsheets_request.json
Find cells containing specific text (read all then filter):
curl -s "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheet-id}/values/Sheet1" --header "Authorization: Bearer $(printenv GOOGLE_SHEETS_TOKEN)" | jq '[.values[] | select(.[0] | ascii_downcase | contains("search_term"))]'
| Notation | Description |
|---|---|
Sheet1!A1 | Single cell A1 in Sheet1 |
Sheet1!A1:B2 | Range from A1 to B2 |
Sheet1!A:A | Entire column A |
Sheet1!1:1 | Entire row 1 |
Sheet1!A1:C | From A1 to end of column C |
'Sheet Name'!A1 | Sheet names with spaces need quotes |
USER_ENTERED for formulas, RAW for literal strings%21 in URLs (e.g., Sheet1%21A1:D10)Weekly Installs
275
Repository
GitHub Stars
48
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex251
opencode249
gemini-cli245
github-copilot233
claude-code205
cursor203
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
27,400 周安装
竞争对手研究指南:SEO、内容、反向链接与定价分析工具
231 周安装
Azure 工作负载自动升级评估工具 - 支持 Functions、App Service 计划与 SKU 迁移
231 周安装
Kaizen持续改进方法论:软件开发中的渐进式优化与防错设计实践指南
231 周安装
软件UI/UX设计指南:以用户为中心的设计原则、WCAG可访问性与平台规范
231 周安装
Apify 网络爬虫和自动化平台 - 无需编码抓取亚马逊、谷歌、领英等网站数据
231 周安装
llama.cpp 中文指南:纯 C/C++ LLM 推理,CPU/非 NVIDIA 硬件优化部署
231 周安装