n8n-nodes-excel-ai 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hueyan Chen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,618 @@
1
+ # n8n-nodes-excel-ai
2
+
3
+ ![n8n](https://img.shields.io/badge/n8n-Community%20Node-FF6D5A)
4
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
5
+ ![Version](https://img.shields.io/npm/v/n8n-nodes-excel-ai)
6
+
7
+ A powerful n8n community node for performing CRUD (Create, Read, Update, Delete) operations on Excel files with **AI Agent support**. Works seamlessly with n8n AI Agents for natural language Excel operations.
8
+
9
+ ## โœจ Features
10
+
11
+ ### ๐Ÿค– AI Agent Integration
12
+ - **Native AI Support**: Works as AI Agent Tool (`usableAsTool: true`)
13
+ - **Natural Language**: AI can interact with Excel files using conversational queries
14
+ - **Auto Column Mapping**: Automatically detects and maps columns from your spreadsheets
15
+ - **Smart Data Handling**: Accepts JSON data with intelligent field mapping
16
+
17
+ ### ๐Ÿ“Š Complete CRUD Operations
18
+ - **Read**: Query data with filters and pagination
19
+ - **Create**: Add new rows with automatic column mapping
20
+ - **Update**: Modify existing rows with partial updates
21
+ - **Delete**: Remove rows by row number
22
+ - **Search**: Find rows with advanced matching (exact, contains, starts/ends with)
23
+
24
+ ### ๐Ÿ—‚๏ธ Worksheet Management
25
+ - **List Worksheets**: Get all sheets in a workbook
26
+ - **Create Worksheet**: Add new sheets with optional initial data
27
+ - **Delete Worksheet**: Remove sheets from workbook
28
+ - **Rename Worksheet**: Rename existing worksheets
29
+ - **Copy Worksheet**: Duplicate worksheets with all data and formatting
30
+ - **Get Worksheet Info**: Retrieve detailed worksheet information including columns
31
+
32
+ ### ๐Ÿ”„ Flexible Input Modes
33
+ - **File Path**: Work with Excel files from your file system
34
+ - **Binary Data**: Process files from previous workflow steps
35
+
36
+ ## ๐Ÿ“ฆ Installation
37
+
38
+ ### Option 1: npm (Recommended)
39
+
40
+ ```bash
41
+ # Navigate to n8n custom nodes directory
42
+ cd ~/.n8n/nodes
43
+
44
+ # Install the package
45
+ npm install n8n-nodes-excel-ai
46
+ ```
47
+
48
+ ### Option 2: Docker
49
+
50
+ Add to your `docker-compose.yml`:
51
+
52
+ ```yaml
53
+ version: '3.7'
54
+
55
+ services:
56
+ n8n:
57
+ image: n8nio/n8n
58
+ environment:
59
+ - NODE_FUNCTION_ALLOW_EXTERNAL=n8n-nodes-excel-ai
60
+ - N8N_CUSTOM_EXTENSIONS=/home/node/.n8n/custom
61
+ volumes:
62
+ - ~/.n8n/custom:/home/node/.n8n/custom
63
+ ```
64
+
65
+ Then install inside the container:
66
+
67
+ ```bash
68
+ docker exec -it <n8n-container> npm install n8n-nodes-excel-ai
69
+ ```
70
+
71
+ ### Option 3: Manual Installation
72
+
73
+ ```bash
74
+ # Clone the repository
75
+ git clone https://github.com/code4Copilot/n8n-nodes-excel-ai.git
76
+ cd n8n-nodes-excel-ai
77
+
78
+ # Install dependencies
79
+ npm install
80
+
81
+ # Build the node
82
+ npm run build
83
+
84
+ # Link to n8n
85
+ npm link
86
+ cd ~/.n8n/nodes
87
+ npm link n8n-nodes-excel-ai
88
+ ```
89
+
90
+ ## ๐Ÿš€ Quick Start
91
+
92
+ ### Basic Usage
93
+
94
+ #### 1. Read Data from Excel
95
+
96
+ ```javascript
97
+ // Node Configuration
98
+ Resource: Row
99
+ Operation: Read Rows
100
+ File Path: /data/customers.xlsx
101
+ Sheet Name: Customers
102
+ Start Row: 2
103
+ End Row: 0 (read all)
104
+
105
+ // Output
106
+ [
107
+ { "_rowNumber": 2, "Name": "John Doe", "Email": "john@example.com" },
108
+ { "_rowNumber": 3, "Name": "Jane Smith", "Email": "jane@example.com" }
109
+ ]
110
+ ```
111
+
112
+ #### 2. Add New Row
113
+
114
+ ```javascript
115
+ // Node Configuration
116
+ Resource: Row
117
+ Operation: Append Row
118
+ File Path: /data/customers.xlsx
119
+ Sheet Name: Customers
120
+ Row Data: {"Name": "Bob Wilson", "Email": "bob@example.com", "Status": "Active"}
121
+
122
+ // Output
123
+ {
124
+ "success": true,
125
+ "operation": "appendRow",
126
+ "rowNumber": 15,
127
+ "message": "Row added successfully at row 15"
128
+ }
129
+ ```
130
+
131
+ #### 3. Find Rows
132
+
133
+ ```javascript
134
+ // Node Configuration
135
+ Resource: Row
136
+ Operation: Find Rows
137
+ File Path: /data/customers.xlsx
138
+ Sheet Name: Customers
139
+ Search Column: Status
140
+ Search Value: Active
141
+ Match Type: exact
142
+
143
+ // Output
144
+ [
145
+ { "_rowNumber": 2, "Name": "John Doe", "Status": "Active" },
146
+ { "_rowNumber": 5, "Name": "Alice Johnson", "Status": "Active" }
147
+ ]
148
+ ```
149
+
150
+ ### ๐Ÿค– AI Agent Usage Examples
151
+
152
+ #### Example 1: Natural Language Query
153
+
154
+ **User:** "Show me all customers from the customers.xlsx file"
155
+
156
+ **AI Agent Execution:**
157
+ ```javascript
158
+ {
159
+ "operation": "readRows",
160
+ "filePath": "/data/customers.xlsx",
161
+ "sheetName": "Customers",
162
+ "startRow": 2,
163
+ "endRow": 0
164
+ }
165
+ ```
166
+
167
+ #### Example 2: Add Data via AI
168
+
169
+ **User:** "Add a new customer named Sarah Johnson with email sarah@example.com"
170
+
171
+ **AI Agent Execution:**
172
+ ```javascript
173
+ {
174
+ "operation": "appendRow",
175
+ "filePath": "/data/customers.xlsx",
176
+ "sheetName": "Customers",
177
+ "rowData": {
178
+ "Name": "Sarah Johnson",
179
+ "Email": "sarah@example.com"
180
+ }
181
+ }
182
+ ```
183
+
184
+ #### Example 3: Search with AI
185
+
186
+ **User:** "Find all active customers in Boston"
187
+
188
+ **AI Agent Execution:**
189
+ ```javascript
190
+ {
191
+ "operation": "findRows",
192
+ "filePath": "/data/customers.xlsx",
193
+ "sheetName": "Customers",
194
+ "searchColumn": "Status",
195
+ "searchValue": "Active",
196
+ "matchType": "exact"
197
+ }
198
+ ```
199
+
200
+ Then filter by City in subsequent operation.
201
+
202
+ ## ๐Ÿ“š Operations Reference
203
+
204
+ ### Row Operations
205
+
206
+ #### Read Rows
207
+ - **Purpose**: Read data from Excel file
208
+ - **Parameters**:
209
+ - `startRow`: Starting row number (default: 2)
210
+ - `endRow`: Ending row number (0 = all rows)
211
+ - **Returns**: Array of row objects with `_rowNumber` field
212
+
213
+ #### Append Row
214
+ - **Purpose**: Add new row at the end of the sheet
215
+ - **Parameters**:
216
+ - `rowData`: JSON object with column names and values
217
+ - **Returns**: Success status and new row number
218
+
219
+ #### Insert Row
220
+ - **Purpose**: Insert row at specific position
221
+ - **Parameters**:
222
+ - `rowNumber`: Position to insert
223
+ - `rowData`: JSON object with column names and values
224
+ - **Returns**: Success status and row number
225
+
226
+ #### Update Row
227
+ - **Purpose**: Update existing row
228
+ - **Parameters**:
229
+ - `rowNumber`: Row to update
230
+ - `updatedData`: JSON object with fields to update
231
+ - **Returns**: Success status and updated fields
232
+
233
+ #### Delete Row
234
+ - **Purpose**: Remove specific row
235
+ - **Parameters**:
236
+ - `rowNumber`: Row to delete (cannot be 1 - header row)
237
+ - **Returns**: Success status
238
+
239
+ #### Find Rows
240
+ - **Purpose**: Search for rows matching criteria
241
+ - **Parameters**:
242
+ - `searchColumn`: Column to search in
243
+ - `searchValue`: Value to search for
244
+ - `matchType`: exact | contains | startsWith | endsWith
245
+ - `returnRowNumbers`: Return only row numbers (default: false)
246
+ - **Returns**: Array of matching rows or row numbers
247
+
248
+ ### Worksheet Operations
249
+
250
+ #### List Worksheets
251
+ - **Purpose**: Get all worksheets in workbook
252
+ - **Parameters**:
253
+ - `includeHidden`: Include hidden sheets (default: false)
254
+ - **Returns**: Array of worksheet info
255
+
256
+ #### Create Worksheet
257
+ - **Purpose**: Create new worksheet
258
+ - **Parameters**:
259
+ - `newSheetName`: Name for new sheet
260
+ - `initialData`: Optional array of objects for initial data
261
+ - **Returns**: Success status and sheet info
262
+
263
+ #### Delete Worksheet
264
+ - **Purpose**: Remove worksheet from workbook
265
+ - **Parameters**:
266
+ - `worksheetName`: Name of sheet to delete
267
+ - **Returns**: Success status
268
+
269
+ #### Rename Worksheet
270
+ - **Purpose**: Rename an existing worksheet
271
+ - **Parameters**:
272
+ - `worksheetName`: Current name of the sheet
273
+ - `newSheetName`: New name for the sheet
274
+ - **Returns**: Success status with old and new names
275
+
276
+ **Example:**
277
+ ```javascript
278
+ {
279
+ "worksheetOperation": "renameWorksheet",
280
+ "filePath": "/data/reports.xlsx",
281
+ "worksheetName": "Sheet1",
282
+ "newSheetName": "Sales_2024",
283
+ "autoSave": true
284
+ }
285
+ ```
286
+
287
+ #### Copy Worksheet
288
+ - **Purpose**: Duplicate a worksheet with all data and formatting
289
+ - **Parameters**:
290
+ - `worksheetName`: Name of sheet to copy
291
+ - `newSheetName`: Name for the copied sheet
292
+ - **Returns**: Success status with source and new sheet names, row count
293
+
294
+ **Example:**
295
+ ```javascript
296
+ {
297
+ "worksheetOperation": "copyWorksheet",
298
+ "filePath": "/data/templates.xlsx",
299
+ "worksheetName": "Template_2024",
300
+ "newSheetName": "Template_2025",
301
+ "autoSave": true
302
+ }
303
+ ```
304
+
305
+ **Output:**
306
+ ```javascript
307
+ {
308
+ "success": true,
309
+ "operation": "copyWorksheet",
310
+ "sourceName": "Template_2024",
311
+ "newName": "Template_2025",
312
+ "rowCount": 50
313
+ }
314
+ ```
315
+
316
+ #### Get Worksheet Info
317
+ - **Purpose**: Retrieve detailed information about a worksheet
318
+ - **Parameters**:
319
+ - `worksheetName`: Name of the sheet
320
+ - **Returns**: Detailed worksheet information including columns
321
+
322
+ **Example:**
323
+ ```javascript
324
+ {
325
+ "worksheetOperation": "getWorksheetInfo",
326
+ "filePath": "/data/database.xlsx",
327
+ "worksheetName": "Users"
328
+ }
329
+ ```
330
+
331
+ **Output:**
332
+ ```javascript
333
+ {
334
+ "operation": "getWorksheetInfo",
335
+ "sheetName": "Users",
336
+ "rowCount": 150,
337
+ "columnCount": 6,
338
+ "actualRowCount": 151,
339
+ "actualColumnCount": 6,
340
+ "state": "visible",
341
+ "columns": [
342
+ {
343
+ "index": 1,
344
+ "letter": "A",
345
+ "header": "UserID",
346
+ "width": 15
347
+ },
348
+ {
349
+ "index": 2,
350
+ "letter": "B",
351
+ "header": "Name",
352
+ "width": 25
353
+ },
354
+ {
355
+ "index": 3,
356
+ "letter": "C",
357
+ "header": "Email",
358
+ "width": 30
359
+ }
360
+ // ... more columns
361
+ ]
362
+ }
363
+ ```
364
+
365
+ ## ๐Ÿค– Using with AI Agents
366
+
367
+ ### Setup
368
+
369
+ This node is designed to work seamlessly with n8n AI Agents. The node is configured with `usableAsTool: true`, making it automatically available to AI Agents.
370
+
371
+ ### Enabling AI Parameters
372
+
373
+ 1. In the node configuration, look for parameters with a โœจ sparkle icon
374
+ 2. Click the โœจ icon next to any parameter to enable AI auto-fill
375
+ 3. The AI Agent can now automatically set values for that parameter
376
+
377
+ ### AI Agent Examples
378
+
379
+ #### Example 1: Natural Language Data Operations
380
+
381
+ **Workflow Setup:**
382
+ ```
383
+ AI Agent โ†’ Excel AI Node
384
+ ```
385
+
386
+ **User Query:** "Get all customers from the Excel file and show me those in New York"
387
+
388
+ **AI Agent Actions:**
389
+ 1. Uses Excel AI to read all rows
390
+ 2. Filters results for New York customers
391
+ 3. Returns formatted results
392
+
393
+ #### Example 2: Multi-Step Operations
394
+
395
+ **User Query:** "Copy the 2024 template sheet to create a 2025 version, then add January data"
396
+
397
+ **AI Agent Actions:**
398
+ 1. Uses `copyWorksheet` operation to duplicate the sheet
399
+ 2. Uses `appendRow` to add new data rows
400
+ 3. Confirms completion
401
+
402
+ #### Example 3: Data Analysis
403
+
404
+ **User Query:** "Show me the structure of the Users worksheet"
405
+
406
+ **AI Agent Actions:**
407
+ 1. Uses `getWorksheetInfo` to retrieve column details
408
+ 2. Formats and presents the structure
409
+ 3. Suggests data operations based on columns
410
+
411
+ ### Best Practices for AI Integration
412
+
413
+ 1. **Clear File Paths**: Use absolute paths for files
414
+ 2. **Descriptive Sheet Names**: Name worksheets clearly for AI understanding
415
+ 3. **Consistent Column Headers**: Use clear, descriptive column names
416
+ 4. **Enable AI Parameters**: Allow AI to control operation and sheet selection
417
+ 5. **Error Context**: AI will handle and explain errors naturally
418
+
419
+ ## ๐Ÿ”ง Advanced Features
420
+
421
+ ### Automatic Column Mapping
422
+
423
+ The node automatically detects columns from the header row (row 1) and maps your JSON data accordingly:
424
+
425
+ ```javascript
426
+ // Excel Headers: Name | Email | Phone | Status
427
+
428
+ // Your Input
429
+ {
430
+ "Name": "John Doe",
431
+ "Email": "john@example.com",
432
+ "Status": "Active"
433
+ }
434
+
435
+ // Automatically mapped to correct columns
436
+ // Phone will be left empty
437
+ ```
438
+
439
+ ### Smart Data Types
440
+
441
+ - **Strings**: Handled automatically
442
+ - **Numbers**: Preserved as numeric types
443
+ - **Dates**: Handled by ExcelJS
444
+ - **Formulas**: Preserved when present
445
+ - **Empty cells**: Returned as empty strings
446
+
447
+ ### Error Handling
448
+
449
+ ```javascript
450
+ // Error Response Format
451
+ {
452
+ "error": "Column 'InvalidColumn' not found",
453
+ "operation": "findRows",
454
+ "resource": "row"
455
+ }
456
+ ```
457
+
458
+ Enable "Continue on Fail" in node settings to handle errors gracefully in workflows.
459
+
460
+ ## โš™๏ธ Configuration Options
461
+
462
+ ### File Path vs Binary Data
463
+
464
+ **File Path Mode:**
465
+ - Best for: Server-side operations, scheduled workflows
466
+ - Pros: Direct file access, auto-save support
467
+ - Cons: Requires file system access
468
+
469
+ **Binary Data Mode:**
470
+ - Best for: Processing uploaded files, workflow data
471
+ - Pros: Works with any file source, portable
472
+ - Cons: Must handle file saving manually
473
+
474
+ ### Auto Save
475
+
476
+ When enabled (File Path mode only):
477
+ - Changes are automatically saved to the original file
478
+ - Disable for preview/validation before saving
479
+
480
+ ## ๐Ÿ’ก Examples
481
+
482
+ ### Example 1: Data Import Workflow
483
+
484
+ ```
485
+ HTTP Request (Upload) โ†’ Excel CRUD (Append Row) โ†’ Slack (Notify)
486
+ ```
487
+
488
+ ### Example 2: Data Validation
489
+
490
+ ```
491
+ Schedule Trigger โ†’ Excel CRUD (Read Rows) โ†’ If (Validate) โ†’ Excel CRUD (Update Row)
492
+ ```
493
+
494
+ ### Example 3: AI-Powered Data Entry
495
+
496
+ ```
497
+ AI Agent Chat โ†’ Excel CRUD (Multiple Operations) โ†’ Response
498
+ ```
499
+
500
+ ### Example 4: Report Generation
501
+
502
+ ```
503
+ Excel CRUD (Read Rows) โ†’ Aggregate โ†’ Excel CRUD (Create Worksheet) โ†’ Email
504
+ ```
505
+
506
+ ## ๐Ÿงช Testing
507
+
508
+ ```bash
509
+ # Run all tests
510
+ npm test
511
+
512
+ # Run with coverage
513
+ npm test -- --coverage
514
+
515
+ # Watch mode
516
+ npm test -- --watch
517
+ ```
518
+
519
+ ## ๐Ÿ› ๏ธ Development
520
+
521
+ ```bash
522
+ # Clone and install
523
+ git clone https://github.com/code4Copilot/n8n-nodes-excel-ai.git
524
+ cd n8n-nodes-excel-ai
525
+ npm install
526
+
527
+ # Build
528
+ npm run build
529
+
530
+ # Watch mode for development
531
+ npm run dev
532
+
533
+ # Lint
534
+ npm run lint
535
+ npm run lintfix
536
+ ```
537
+
538
+ ## ๐Ÿ“ Changelog
539
+
540
+ ### v1.0.0 (Latest)
541
+ - โœจ Added full AI Agent integration (`usableAsTool: true`)
542
+ - โœจ Automatic column detection and mapping
543
+ - โœจ Enhanced JSON data handling
544
+ - ๐Ÿ“ Improved parameter descriptions for AI
545
+ - ๐Ÿ› Better error messages
546
+ - ๐Ÿ“š Comprehensive AI usage documentation
547
+ - Added worksheet operations
548
+ - Binary data support
549
+ - Auto-save option
550
+ - Find rows operation
551
+ - Advanced search with match types
552
+ - Insert row operation
553
+ - Initial release
554
+ - Basic CRUD operations
555
+ - File path support
556
+
557
+ ## ๐Ÿค Contributing
558
+
559
+ Contributions are welcome! Please feel free to submit a Pull Request.
560
+
561
+ 1. Fork the repository
562
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
563
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
564
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
565
+ 5. Open a Pull Request
566
+
567
+ ## ๐Ÿ“„ License
568
+
569
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
570
+
571
+ ```
572
+ MIT License
573
+
574
+ Copyright (c) 2024 Your Name
575
+
576
+ Permission is hereby granted, free of charge, to any person obtaining a copy
577
+ of this software and associated documentation files (the "Software"), to deal
578
+ in the Software without restriction, including without limitation the rights
579
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
580
+ copies of the Software, and to permit persons to whom the Software is
581
+ furnished to do so, subject to the following conditions:
582
+
583
+ The above copyright notice and this permission notice shall be included in all
584
+ copies or substantial portions of the Software.
585
+
586
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
587
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
588
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
589
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
590
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
591
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
592
+ SOFTWARE.
593
+ ```
594
+
595
+ ## ๐Ÿ™ Acknowledgments
596
+
597
+ - Built for the [n8n](https://n8n.io) workflow automation platform
598
+ - Uses [ExcelJS](https://github.com/exceljs/exceljs) for Excel file processing
599
+ - Inspired by the n8n community
600
+
601
+ ## ๐Ÿ†˜ Support
602
+
603
+ - **Issues**: [GitHub Issues](https://github.com/code4Copilot/n8n-nodes-excel-ai/issues)
604
+ - **Discussions**: [GitHub Discussions](https://github.com/code4Copilot/n8n-nodes-excel-ai/discussions)
605
+ - **n8n Community**: [n8n Community Forum](https://community.n8n.io)
606
+
607
+ ## ๐Ÿ’– Show Your Support
608
+
609
+ If you find this node useful, please consider:
610
+ - โญ Starring the repository
611
+ - ๐Ÿ› Reporting bugs
612
+ - ๐Ÿ’ก Suggesting new features
613
+ - ๐Ÿ“ Improving documentation
614
+ - ๐Ÿ”ง Contributing code
615
+
616
+ ---
617
+
618
+ **Made with โค๏ธ for the n8n community**