{
  "nodes": [
    {
      "id": "excel-import",
      "type": "canvas-node",
      "position": { "x": 80, "y": 220 },
      "data": {
        "id": "excel-import",
        "name": "导入待清洗表格",
        "engineType": "TableImportBatch",
        "creatorType": "rpa-TableImportBatch",
        "icon": "IconDatabase",
        "inputs": [{ "type": "main", "index": 0 }],
        "outputs": [{ "type": "main", "index": 0 }],
        "parameters": {
          "path": "D:\\data\\sales.xlsx",
          "header": true,
          "headerRow": 1,
          "sheets": [],
          "outputField": "workbook"
        },
        "retryOnFail": false,
        "onError": "stopWorkflow"
      }
    },
    {
      "id": "excel-clean",
      "type": "canvas-node",
      "position": { "x": 400, "y": 220 },
      "data": {
        "id": "excel-clean",
        "name": "去空行并统一列名",
        "engineType": "Code",
        "creatorType": "transform",
        "icon": "IconCode",
        "inputs": [{ "type": "main", "index": 0 }],
        "outputs": [{ "type": "main", "index": 0 }],
        "parameters": {
          "mode": "runOnceForAllItems",
          "code": "const first = $input.first();\nconst workbook = first && first.json ? first.json.workbook : null;\nif (!workbook || !Array.isArray(workbook.sheets) || !workbook.sheets.length)\n  throw new Error('没有读取到工作表：请先把导入节点的文件路径改成你自己的 Excel 文件');\nconst sheet = workbook.sheets[0];\nconst columns = (sheet.columns || []).map(name => String(name).trim());\nconst rows = [];\nfor (const row of sheet.rows || []) {\n  const cells = (row || []).map(value => (value === null || value === undefined ? '' : String(value).trim()));\n  if (cells.every(cell => cell === '')) continue;\n  rows.push(cells);\n}\nconst source = String(workbook.path || '');\nconst outputPath = source.replace(/\\.[^.\\\\/]+$/, '') + '-cleaned.xlsx';\nreturn [{ json: {\n  tables: [{ name: sheet.name || '清洗结果', columns: columns, rows: rows }],\n  rowCount: rows.length,\n  outputPath: outputPath,\n}}];"
        },
        "retryOnFail": false,
        "onError": "stopWorkflow"
      }
    },
    {
      "id": "excel-export",
      "type": "canvas-node",
      "position": { "x": 720, "y": 220 },
      "data": {
        "id": "excel-export",
        "name": "导出清洗结果",
        "engineType": "TableExportBatch",
        "creatorType": "rpa-TableExportBatch",
        "icon": "IconDatabase",
        "inputs": [{ "type": "main", "index": 0 }],
        "outputs": [{ "type": "main", "index": 0 }],
        "parameters": {
          "tables": "={{ $json.tables }}",
          "path": "={{ $json.outputPath }}",
          "header": true,
          "conflict": "overwrite",
          "outputField": "exported"
        },
        "retryOnFail": false,
        "onError": "stopWorkflow"
      }
    }
  ],
  "edges": [
    { "id": "excel-import-excel-clean", "source": "excel-import", "target": "excel-clean", "sourceHandle": "outputs/main/0", "targetHandle": "inputs/main/0" },
    { "id": "excel-clean-excel-export", "source": "excel-clean", "target": "excel-export", "sourceHandle": "outputs/main/0", "targetHandle": "inputs/main/0" }
  ],
  "variables": {},
  "pinData": {},
  "settings": { "scheduleEnabled": false, "maxNodeExecutions": 10000, "executionTimeout": 300 }
}
