google-sheets

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Google Sheets Skill

Google Sheets技能

Overview

概述

Claude can work with Google Sheets to create spreadsheets, enter and analyze data, build formulas, create charts, and automate data workflows. This includes reading data, performing calculations, and generating insights from spreadsheet data.
Claude可以处理Google Sheets电子表格,包括创建表格、输入和分析数据、构建公式、创建图表以及自动化数据工作流。这涵盖了读取数据、执行计算以及从电子表格数据中生成洞察。

Quick Install

快速安装

bash
curl -sSL https://canifi.com/skills/google-sheets/install.sh | bash
Or manually:
bash
cp -r skills/google-sheets ~/.canifi/skills/
bash
curl -sSL https://canifi.com/skills/google-sheets/install.sh | bash
或手动安装:
bash
cp -r skills/google-sheets ~/.canifi/skills/

Setup

配置

Configure via canifi-env:
bash
undefined
通过canifi-env进行配置:
bash
undefined

First, ensure canifi-env is installed:

首先,确保已安装canifi-env:

canifi-env set GOOGLE_EMAIL "your-email@gmail.com"
undefined
canifi-env set GOOGLE_EMAIL "your-email@gmail.com"
undefined

Privacy & Authentication

隐私与认证

Your credentials, your choice. Canifi LifeOS respects your privacy.
你的凭据,由你掌控。Canifi LifeOS尊重你的隐私。

Option 1: Manual Browser Login (Recommended)

选项1:手动浏览器登录(推荐)

If you prefer not to share credentials with Claude Code:
  1. Complete the Browser Automation Setup using CDP mode
  2. Login to the service manually in the Playwright-controlled Chrome window
  3. Claude will use your authenticated session without ever seeing your password
如果你不想与Claude Code共享凭据:
  1. 使用CDP模式完成浏览器自动化设置
  2. 在Playwright控制的Chrome窗口中手动登录该服务
  3. Claude将使用你的已认证会话,且永远不会看到你的密码

Option 2: Environment Variables

选项2:环境变量

If you're comfortable sharing credentials, you can store them locally:
bash
canifi-env set SERVICE_EMAIL "your-email"
canifi-env set SERVICE_PASSWORD "your-password"
Note: Credentials stored in canifi-env are only accessible locally on your machine and are never transmitted.
如果你愿意共享凭据,可以将其存储在本地:
bash
canifi-env set SERVICE_EMAIL "your-email"
canifi-env set SERVICE_PASSWORD "your-password"
注意:存储在canifi-env中的凭据仅能在你的本地机器上访问,绝不会被传输。

Capabilities

功能

  • Create new spreadsheets and worksheets
  • Read and analyze spreadsheet data
  • Enter and edit cell values
  • Build and apply formulas and functions
  • Create charts and visualizations
  • Format cells, rows, and columns
  • Sort and filter data
  • Create pivot tables
  • Import and export data (CSV, XLSX)
  • Apply conditional formatting
  • Protect sheets and ranges
  • Share and collaborate with permissions
  • 创建新的电子表格和工作表
  • 读取和分析电子表格数据
  • 输入和编辑单元格值
  • 构建和应用公式与函数
  • 创建图表和可视化效果
  • 设置单元格、行和列的格式
  • 排序和筛选数据
  • 创建透视表
  • 导入和导出数据(CSV、XLSX格式)
  • 应用条件格式
  • 保护工作表和单元格区域
  • 设置权限以实现共享协作

Usage Examples

使用示例

Example 1: Create Budget Spreadsheet

示例1:创建预算电子表格

User: "Create a monthly budget spreadsheet"
Claude: Creates new sheet with columns for Category, Budgeted, Actual, Difference.
        Adds SUM formulas for totals, conditional formatting for over-budget items.
        Returns: "Created budget spreadsheet: [link]"
用户:"创建一份月度预算电子表格"
Claude:创建包含“类别”、“预算金额”、“实际支出”、“差额”列的新表格。
        添加用于计算总计的SUM公式,为超预算项目设置条件格式。
        返回:"已创建预算电子表格:[链接]"

Example 2: Analyze Data

示例2:分析数据

User: "What were my top 5 expenses last month?"
Claude: Opens expense sheet, sorts by amount descending, reads top 5 entries.
        Reports: "Top 5 expenses: 1. Rent $1500, 2. Car Payment $450..."
用户:"我上个月的前5项支出是什么?"
Claude:打开支出表格,按金额降序排序,读取前5条记录。
        回复:"前5项支出:1. 房租 $1500,2. 车贷 $450..."

Example 3: Add Formula

示例3:添加公式

User: "Add a formula to calculate the running total in column D"
Claude: Navigates to column D, enters formula =SUM($C$2:C2) in first data row,
        copies formula down to all rows. Confirms: "Running total formula applied"
用户:"添加一个公式来计算D列的累计总额"
Claude:导航至D列,在第一行数据单元格中输入公式=SUM($C$2:C2),
        将公式向下复制到所有行。确认:"已应用累计总额公式"

Example 4: Create Chart

示例4:创建图表

User: "Create a pie chart of spending by category"
Claude: Selects category and amount columns, inserts pie chart,
        applies labels and formatting. Reports: "Pie chart created"
用户:"创建按类别划分的支出饼图"
Claude:选择类别和金额列,插入饼图,
        添加标签并设置格式。回复:"已创建饼图"

Authentication Flow

认证流程

  1. Claude navigates to sheets.google.com via Playwright MCP
  2. Authenticates with GOOGLE_EMAIL if needed
  3. Handles 2FA if prompted (notifies user via iMessage)
  4. Maintains session for subsequent spreadsheet operations
  1. Claude通过Playwright MCP导航至sheets.google.com
  2. 如有需要,使用GOOGLE_EMAIL进行认证
  3. 若提示双因素认证,将通过iMessage通知用户
  4. 维持会话以进行后续的电子表格操作

Selectors Reference

选择器参考

javascript
// New spreadsheet button
'#newButton' or '[aria-label="New"]'

// Spreadsheet title
'.docs-title-input'

// Cell reference box
'#t-name-box'

// Formula bar
'#t-formula-bar-input'

// Active cell
'.cell-input'

// Sheet tabs
'.docs-sheet-tab'

// Add sheet button
'#sheet-add-button'

// Menu bar
'.menu-button'

// Insert menu
'#docs-insert-menu'

// Format menu
'#docs-format-menu'

// Chart dialog
'.charts-dialog'

// Filter button
'[aria-label="Create a filter"]'
javascript
// New spreadsheet button
'#newButton' or '[aria-label="New"]'

// Spreadsheet title
'.docs-title-input'

// Cell reference box
'#t-name-box'

// Formula bar
'#t-formula-bar-input'

// Active cell
'.cell-input'

// Sheet tabs
'.docs-sheet-tab'

// Add sheet button
'#sheet-add-button'

// Menu bar
'.menu-button'

// Insert menu
'#docs-insert-menu'

// Format menu
'#docs-format-menu'

// Chart dialog
'.charts-dialog'

// Filter button
'[aria-label="Create a filter"]'

Common Formulas Reference

常用公式参考

=SUM(A1:A10)           // Sum range
=AVERAGE(A1:A10)       // Average
=VLOOKUP(key,range,col,false)  // Vertical lookup
=IF(condition,true,false)       // Conditional
=COUNTIF(range,criteria)        // Count matching
=SUMIF(range,criteria,sum_range) // Sum matching
=CONCATENATE(A1," ",B1)         // Join text
=TODAY()               // Current date
=GOOGLEFINANCE("GOOG") // Stock price
=SUM(A1:A10)           // Sum range
=AVERAGE(A1:A10)       // Average
=VLOOKUP(key,range,col,false)  // Vertical lookup
=IF(condition,true,false)       // Conditional
=COUNTIF(range,criteria)        // Count matching
=SUMIF(range,criteria,sum_range) // Sum matching
=CONCATENATE(A1," ",B1)         // Join text
=TODAY()               // Current date
=GOOGLEFINANCE("GOOG") // Stock price

Error Handling

错误处理

  • Login Failed: Retry 3 times, notify user via iMessage
  • Session Expired: Re-authenticate automatically
  • Spreadsheet Not Found: Search Drive for similar names, ask user to clarify
  • Formula Error: Identify error type (#REF!, #VALUE!, etc.), suggest fix
  • Permission Denied: Notify user, offer to request access
  • Rate Limited: Wait and retry with exponential backoff
  • 登录失败:重试3次,通过iMessage通知用户
  • 会话过期:自动重新认证
  • 未找到电子表格:在云端硬盘中搜索相似名称,请求用户澄清
  • 公式错误:识别错误类型(#REF!、#VALUE!等),建议修复方案
  • 权限不足:通知用户,提供请求访问权限的选项
  • 速率限制:等待后使用指数退避策略重试

Self-Improvement Instructions

自我改进说明

When you learn a better way to accomplish a task with Google Sheets:
  1. Document the improvement in your response
  2. Suggest updating this skill file with the new approach
  3. Include specific formulas or techniques that worked better
  4. Note keyboard shortcuts for efficiency
当你掌握了使用Google Sheets完成任务的更优方法时:
  1. 在回复中记录该改进点
  2. 建议更新此技能文件以采用新方法
  3. 附上效果更好的具体公式或技术
  4. 记录提高效率的键盘快捷键

Notes

注意事项

  • Google Sheets auto-saves changes
  • Large datasets may require pagination or filtering for performance
  • Some functions have usage limits (IMPORTDATA, GOOGLEFINANCE)
  • Keyboard shortcuts: Ctrl+C/V for copy/paste, Ctrl+Z for undo
  • Maximum cell limit: 10 million cells per spreadsheet
  • For heavy data processing, consider Apps Script automation
  • Google Sheets会自动保存更改
  • 大型数据集可能需要分页或筛选以保证性能
  • 部分函数存在使用限制(如IMPORTDATA、GOOGLEFINANCE)
  • 键盘快捷键:Ctrl+C/V用于复制/粘贴,Ctrl+Z用于撤销
  • 单个电子表格的最大单元格限制为1000万个
  • 对于大量数据处理,建议使用Apps Script自动化