8
n8n 中文网amn8n.com

Google Sheets复制工作流

中级

这是一个AI, IT Ops领域的自动化工作流,包含 15 个节点。主要使用 Code, HttpRequest, GoogleSheets, ManualTrigger, SplitInBatches 等节点,结合人工智能技术实现智能自动化。 Google Sheets复制与丰富自动化

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "YOUR_INSTANCE_ID"
  },
  "name": "Google Sheets 复制工作流",
  "tags": [],
  "nodes": [
    {
      "id": "workflow-overview-sheets",
      "name": "工作流概览",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1450,
        -50
      ],
      "parameters": {
        "color": 2,
        "width": 350,
        "height": 320,
        "content": "# 📊 Google Sheets 复制工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "start-create-note",
      "name": "开始与创建",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        -50
      ],
      "parameters": {
        "color": 3,
        "width": 280,
        "height": 200,
        "content": "## 🚀 开始与创建"
      },
      "typeVersion": 1
    },
    {
      "id": "discovery-note",
      "name": "工作表发现",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        -50
      ],
      "parameters": {
        "color": 1,
        "width": 280,
        "height": 200,
        "content": "## 🔍 工作表发现"
      },
      "typeVersion": 1
    },
    {
      "id": "loop-note",
      "name": "循环处理",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -50
      ],
      "parameters": {
        "color": 5,
        "width": 280,
        "height": 200,
        "content": "## 🔄 循环处理"
      },
      "typeVersion": 1
    },
    {
      "id": "operations-note",
      "name": "工作表操作",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        220,
        -50
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 200,
        "content": "## 📝 工作表操作"
      },
      "typeVersion": 1
    },
    {
      "id": "important-notes",
      "name": "重要注意事项",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        420
      ],
      "parameters": {
        "color": 6,
        "width": 300,
        "height": 150,
        "content": "⚠️ **重要注意事项:**"
      },
      "typeVersion": 1
    },
    {
      "id": "21b7267c-eac9-4f90-b345-614bd6d5a276",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "notes": "Manual trigger - click to start the spreadsheet duplication process",
      "position": [
        -1100,
        200
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "26e0f233-e990-4b98-8184-599583a64498",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Gets spreadsheet metadata - replace YOUR_MASTER_SPREADSHEET_ID with actual ID",
      "position": [
        -660,
        200
      ],
      "parameters": {
        "url": "https://sheets.googleapis.com/v4/spreadsheets/YOUR_MASTER_SPREADSHEET_ID",
        "options": {},
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "googleSheetsOAuth2Api"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "HTTP_HEADER_CREDENTIAL_ID",
          "name": "API Header Auth"
        },
        "googleSheetsOAuth2Api": {
          "id": "GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets Account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d8a02c3f-8b31-4bb1-9052-33963c09da16",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "notes": "Extracts sheet names and IDs from API response",
      "position": [
        -440,
        200
      ],
      "parameters": {
        "jsCode": "const spreadsheet = $input.first().json;\nconst sheets = spreadsheet.sheets;\n\n// Create array of sheet names\nconst sheetList = sheets.map(sheet => ({\n  json: {\n    sheetName: sheet.properties.title,\n    sheetId: sheet.properties.sheetId,\n    index: sheet.properties.index\n  }\n}));\n\nreturn sheetList;"
      },
      "typeVersion": 2
    },
    {
      "id": "d45b8f9a-47ad-4280-ba95-d8b10b0351a2",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "notes": "Processes sheets one by one - output 1 when done, output 2 for each iteration",
      "position": [
        -220,
        200
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "aaff5289-8658-4f5c-b3de-15630e25c537",
      "name": "创建工作表",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Creates new sheet in destination spreadsheet with original name",
      "position": [
        0,
        200
      ],
      "parameters": {
        "title": "={{ $('Loop Over Items').item.json.sheetName }}",
        "options": {},
        "operation": "create",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create New Spreadsheet').item.json.spreadsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets Account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "e33a1701-8a90-4e71-8f1a-f517d26894be",
      "name": "写入工作表",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Writes data to new sheet - preserves all columns from master",
      "position": [
        440,
        275
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "Column1",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Column 1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Column2",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Column 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Column3",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Column 3",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Column4",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Column 4",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Column5",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Column 5",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Column6",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Column 6",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Column7",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Column 7",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Column8",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Column 8",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Column9",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Column 9",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Loop Over Items').item.json.sheetName }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Create New Spreadsheet').item.json.spreadsheetUrl }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets Account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "a46aad80-34cf-4f19-aec6-1896296b40d3",
      "name": "Google Sheets2",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Removes default 'Sheet1' after all sheets are created",
      "position": [
        0,
        0
      ],
      "parameters": {
        "operation": "remove",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Create New Spreadsheet').item.json.spreadsheetUrl }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets Account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "c8439289-b353-4ac5-a0f2-601e66ddf6fb",
      "name": "读取电子表格1",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Reads data from master spreadsheet - one sheet at a time",
      "position": [
        220,
        200
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Loop Over Items').item.json.sheetName }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_MASTER_SPREADSHEET_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_MASTER_SPREADSHEET_ID/edit",
          "cachedResultName": "Master Spreadsheet"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets Account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "2de35627-e071-4f39-9ea7-2e1fa0d56f7c",
      "name": "创建新电子表格",
      "type": "n8n-nodes-base.googleSheets",
      "notes": "Creates new destination spreadsheet - update title as needed",
      "position": [
        -880,
        200
      ],
      "parameters": {
        "title": "Copy of Master Spreadsheet",
        "options": {},
        "resource": "spreadsheet"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets Account"
        }
      },
      "typeVersion": 4.5
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "YOUR_VERSION_ID",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write sheet": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Sheets": {
      "main": [
        [
          {
            "node": "Read Spreadsheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Google Sheets2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Spreadsheet1": {
      "main": [
        [
          {
            "node": "Write sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create New Spreadsheet": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking 'Test workflow'": {
      "main": [
        [
          {
            "node": "Create New Spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 人工智能, IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量15
分类2
节点类型6
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Amit Mehta

Amit Mehta

@amitswba

I'm a workflow automation expert with 15+ years in IT industry. I build smart, scalable n8n workflows for AI automation, marketing, CRM, and SaaS integrations. My focus is on simplifying business processes with tools like OpenAI, WhatsApp, Gmail, and Airtable. I help teams and solopreneurs automate smarter, reduce manual tasks, and grow faster—one workflow at a time.

外部链接
在 n8n.io 查看

分享此工作流