@lab1095/n8n-nodes-sharepoint-excel 0.1.1
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.md +19 -0
- package/README.md +136 -0
- package/dist/credentials/MicrosoftGraphOAuth2Api.credentials.d.ts +9 -0
- package/dist/credentials/MicrosoftGraphOAuth2Api.credentials.js +52 -0
- package/dist/credentials/MicrosoftGraphOAuth2Api.credentials.js.map +1 -0
- package/dist/credentials/icons/Microsoft.svg +1 -0
- package/dist/nodes/SharePointExcel/SharePointExcel.node.d.ts +15 -0
- package/dist/nodes/SharePointExcel/SharePointExcel.node.js +77 -0
- package/dist/nodes/SharePointExcel/SharePointExcel.node.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/router.d.ts +4 -0
- package/dist/nodes/SharePointExcel/actions/router.js +114 -0
- package/dist/nodes/SharePointExcel/actions/router.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/sheet/appendRows.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/sheet/appendRows.js +65 -0
- package/dist/nodes/SharePointExcel/actions/sheet/appendRows.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/sheet/clearSheet.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/sheet/clearSheet.js +27 -0
- package/dist/nodes/SharePointExcel/actions/sheet/clearSheet.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/sheet/deleteSheet.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/sheet/deleteSheet.js +29 -0
- package/dist/nodes/SharePointExcel/actions/sheet/deleteSheet.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/sheet/getSheets.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/sheet/getSheets.js +15 -0
- package/dist/nodes/SharePointExcel/actions/sheet/getSheets.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/sheet/index.d.ts +8 -0
- package/dist/nodes/SharePointExcel/actions/sheet/index.js +51 -0
- package/dist/nodes/SharePointExcel/actions/sheet/index.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/sheet/readRows.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/sheet/readRows.js +42 -0
- package/dist/nodes/SharePointExcel/actions/sheet/readRows.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/sheet/updateRange.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/sheet/updateRange.js +28 -0
- package/dist/nodes/SharePointExcel/actions/sheet/updateRange.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/sheet/upsertRows.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/sheet/upsertRows.js +92 -0
- package/dist/nodes/SharePointExcel/actions/sheet/upsertRows.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/table/getColumns.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/table/getColumns.js +28 -0
- package/dist/nodes/SharePointExcel/actions/table/getColumns.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/table/getRows.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/table/getRows.js +32 -0
- package/dist/nodes/SharePointExcel/actions/table/getRows.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/table/index.d.ts +4 -0
- package/dist/nodes/SharePointExcel/actions/table/index.js +43 -0
- package/dist/nodes/SharePointExcel/actions/table/index.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/table/lookup.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/table/lookup.js +44 -0
- package/dist/nodes/SharePointExcel/actions/table/lookup.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/workbook/addSheet.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/workbook/addSheet.js +29 -0
- package/dist/nodes/SharePointExcel/actions/workbook/addSheet.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/workbook/deleteWorkbook.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/workbook/deleteWorkbook.js +17 -0
- package/dist/nodes/SharePointExcel/actions/workbook/deleteWorkbook.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/workbook/getSheets.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/workbook/getSheets.js +15 -0
- package/dist/nodes/SharePointExcel/actions/workbook/getSheets.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/workbook/getWorkbooks.d.ts +3 -0
- package/dist/nodes/SharePointExcel/actions/workbook/getWorkbooks.js +26 -0
- package/dist/nodes/SharePointExcel/actions/workbook/getWorkbooks.js.map +1 -0
- package/dist/nodes/SharePointExcel/actions/workbook/index.d.ts +5 -0
- package/dist/nodes/SharePointExcel/actions/workbook/index.js +45 -0
- package/dist/nodes/SharePointExcel/actions/workbook/index.js.map +1 -0
- package/dist/nodes/SharePointExcel/api.d.ts +10 -0
- package/dist/nodes/SharePointExcel/api.js +138 -0
- package/dist/nodes/SharePointExcel/api.js.map +1 -0
- package/dist/nodes/SharePointExcel/descriptions.d.ts +20 -0
- package/dist/nodes/SharePointExcel/descriptions.js +523 -0
- package/dist/nodes/SharePointExcel/descriptions.js.map +1 -0
- package/dist/nodes/SharePointExcel/excel.svg +27 -0
- package/dist/nodes/SharePointExcel/listSearch.d.ts +6 -0
- package/dist/nodes/SharePointExcel/listSearch.js +184 -0
- package/dist/nodes/SharePointExcel/listSearch.js.map +1 -0
- package/dist/nodes/SharePointExcel/types.d.ts +57 -0
- package/dist/nodes/SharePointExcel/types.js +3 -0
- package/dist/nodes/SharePointExcel/types.js.map +1 -0
- package/dist/package.json +63 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +63 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright 2022 n8n
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# n8n-nodes-sharepoint-excel
|
|
2
|
+
|
|
3
|
+
This is an n8n community node. It lets you use **Microsoft SharePoint Excel** files in your n8n workflows.
|
|
4
|
+
|
|
5
|
+
This node provides read and write operations for Excel files stored in SharePoint document libraries via Microsoft Graph API. Unlike the native n8n Microsoft Excel node that uses WAC (Web Application Companion) tokens, this node downloads and uploads the entire Excel file using the `exceljs` library, **bypassing WAC token limitations** that often cause issues with SharePoint-hosted files.
|
|
6
|
+
|
|
7
|
+
[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
|
|
8
|
+
|
|
9
|
+
[Installation](#installation)
|
|
10
|
+
[Operations](#operations)
|
|
11
|
+
[Credentials](#credentials)
|
|
12
|
+
[Compatibility](#compatibility)
|
|
13
|
+
[Usage](#usage)
|
|
14
|
+
[Resources](#resources)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
|
|
19
|
+
|
|
20
|
+
## Operations
|
|
21
|
+
|
|
22
|
+
### Sheet
|
|
23
|
+
|
|
24
|
+
| Operation | Description |
|
|
25
|
+
|-----------|-------------|
|
|
26
|
+
| **Get Sheets** | List all worksheets in the workbook |
|
|
27
|
+
| **Get Rows** | Read rows from a sheet with configurable header row and start row |
|
|
28
|
+
| **Append Rows** | Add new rows to the end of a sheet |
|
|
29
|
+
| **Update** | Update a specific cell by reference (e.g., A1, B5) |
|
|
30
|
+
| **Upsert Rows** | Insert or update rows based on a key column |
|
|
31
|
+
| **Clear** | Clear all data from a sheet |
|
|
32
|
+
| **Delete** | Delete a sheet from the workbook |
|
|
33
|
+
|
|
34
|
+
### Table
|
|
35
|
+
|
|
36
|
+
| Operation | Description |
|
|
37
|
+
|-----------|-------------|
|
|
38
|
+
| **Get Rows** | Retrieve all rows from an Excel table |
|
|
39
|
+
| **Get Columns** | Get column definitions from a table |
|
|
40
|
+
| **Lookup** | Find a row by column value |
|
|
41
|
+
|
|
42
|
+
### Workbook
|
|
43
|
+
|
|
44
|
+
| Operation | Description |
|
|
45
|
+
|-----------|-------------|
|
|
46
|
+
| **Get Sheets** | List all sheets in the workbook |
|
|
47
|
+
| **Add Sheet** | Create a new sheet in the workbook |
|
|
48
|
+
| **Delete** | Delete the workbook file |
|
|
49
|
+
| **Get Workbooks** | List all Excel files in the drive |
|
|
50
|
+
|
|
51
|
+
## Credentials
|
|
52
|
+
|
|
53
|
+
This node requires **Microsoft Graph OAuth2** credentials.
|
|
54
|
+
|
|
55
|
+
### Prerequisites
|
|
56
|
+
|
|
57
|
+
1. An Azure account with access to [Azure Portal](https://portal.azure.com)
|
|
58
|
+
2. A Microsoft 365 account with SharePoint access
|
|
59
|
+
|
|
60
|
+
### Setup
|
|
61
|
+
|
|
62
|
+
1. **Register an application in Azure AD:**
|
|
63
|
+
- Go to Azure Portal > Azure Active Directory > App registrations
|
|
64
|
+
- Click "New registration"
|
|
65
|
+
- Name your application (e.g., "n8n SharePoint Excel")
|
|
66
|
+
- Set the redirect URI to your n8n OAuth callback URL
|
|
67
|
+
|
|
68
|
+
2. **Configure API permissions:**
|
|
69
|
+
- Add the following Microsoft Graph permissions:
|
|
70
|
+
- `Sites.ReadWrite.All` - Read and write items in all site collections
|
|
71
|
+
- `Files.ReadWrite.All` - Read and write files in all site collections
|
|
72
|
+
- Grant admin consent for these permissions
|
|
73
|
+
|
|
74
|
+
3. **Create a client secret:**
|
|
75
|
+
- Go to "Certificates & secrets"
|
|
76
|
+
- Create a new client secret and copy the value
|
|
77
|
+
|
|
78
|
+
4. **Configure in n8n:**
|
|
79
|
+
- Add new credentials of type "Microsoft Graph OAuth2 API"
|
|
80
|
+
- Enter your Client ID and Client Secret
|
|
81
|
+
- Complete the OAuth2 authorization flow
|
|
82
|
+
|
|
83
|
+
## Compatibility
|
|
84
|
+
|
|
85
|
+
- Tested with n8n version 1.x and above
|
|
86
|
+
- Requires Microsoft Graph API v1.0
|
|
87
|
+
- Works with `.xlsx` files only
|
|
88
|
+
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
### Why use this node instead of the native Microsoft Excel node?
|
|
92
|
+
|
|
93
|
+
The native n8n Microsoft Excel 365 node uses WAC (Web Application Companion) tokens to interact with Excel files. This works well for OneDrive but often fails with SharePoint-hosted files due to:
|
|
94
|
+
|
|
95
|
+
- Token expiration issues
|
|
96
|
+
- Permission complexities with SharePoint sites
|
|
97
|
+
- WAC service availability problems
|
|
98
|
+
|
|
99
|
+
This node takes a different approach: it **downloads the entire Excel file**, modifies it locally using the `exceljs` library, and **uploads it back**. This bypasses all WAC-related issues.
|
|
100
|
+
|
|
101
|
+
### Finding Required IDs
|
|
102
|
+
|
|
103
|
+
The node provides searchable dropdowns to select:
|
|
104
|
+
- **Site** - Your SharePoint site
|
|
105
|
+
- **Drive** - The document library containing the file
|
|
106
|
+
- **File** - The Excel file to operate on
|
|
107
|
+
- **Sheet/Table** - The specific sheet or table within the file
|
|
108
|
+
|
|
109
|
+
You can also enter IDs manually:
|
|
110
|
+
- **Site ID** format: `contoso.sharepoint.com,site-guid,web-guid`
|
|
111
|
+
- **Drive ID** format: `b!xxxxx...`
|
|
112
|
+
- **File ID** format: Item ID from SharePoint
|
|
113
|
+
|
|
114
|
+
### Reading Data
|
|
115
|
+
|
|
116
|
+
When reading rows, you can configure:
|
|
117
|
+
- **Header Row** - Which row contains column headers (default: 1)
|
|
118
|
+
- **Start Row** - First data row to read (default: 2)
|
|
119
|
+
- **Max Rows** - Limit the number of rows returned (0 = all)
|
|
120
|
+
|
|
121
|
+
### Writing Data
|
|
122
|
+
|
|
123
|
+
When appending or upserting rows:
|
|
124
|
+
- Provide data as a JSON object with column headers as keys
|
|
125
|
+
- For multiple rows, provide an array of objects
|
|
126
|
+
- The node automatically matches columns to existing headers
|
|
127
|
+
|
|
128
|
+
## Resources
|
|
129
|
+
|
|
130
|
+
- [n8n community nodes documentation](https://docs.n8n.io/integrations/#community-nodes)
|
|
131
|
+
- [Microsoft Graph API documentation](https://learn.microsoft.com/en-us/graph/overview)
|
|
132
|
+
- [SharePoint REST API reference](https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service)
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
[MIT](LICENSE.md)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class MicrosoftGraphOAuth2Api implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
extends: string[];
|
|
5
|
+
displayName: string;
|
|
6
|
+
documentationUrl: string;
|
|
7
|
+
icon: "file:icons/Microsoft.svg";
|
|
8
|
+
properties: INodeProperties[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MicrosoftGraphOAuth2Api = void 0;
|
|
4
|
+
class MicrosoftGraphOAuth2Api {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'microsoftGraphOAuth2Api';
|
|
7
|
+
this.extends = ['oAuth2Api'];
|
|
8
|
+
this.displayName = 'Microsoft Graph OAuth2 API';
|
|
9
|
+
this.documentationUrl = 'https://docs.microsoft.com/en-us/graph/auth-v2-user';
|
|
10
|
+
this.icon = 'file:icons/Microsoft.svg';
|
|
11
|
+
this.properties = [
|
|
12
|
+
{
|
|
13
|
+
displayName: 'Grant Type',
|
|
14
|
+
name: 'grantType',
|
|
15
|
+
type: 'hidden',
|
|
16
|
+
default: 'authorizationCode',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Authorization URL',
|
|
20
|
+
name: 'authUrl',
|
|
21
|
+
type: 'hidden',
|
|
22
|
+
default: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
displayName: 'Access Token URL',
|
|
26
|
+
name: 'accessTokenUrl',
|
|
27
|
+
type: 'hidden',
|
|
28
|
+
default: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
displayName: 'Scope',
|
|
32
|
+
name: 'scope',
|
|
33
|
+
type: 'hidden',
|
|
34
|
+
default: 'openid offline_access Sites.ReadWrite.All Files.ReadWrite.All',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
displayName: 'Auth URI Query Parameters',
|
|
38
|
+
name: 'authQueryParameters',
|
|
39
|
+
type: 'hidden',
|
|
40
|
+
default: 'response_mode=query',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
displayName: 'Authentication',
|
|
44
|
+
name: 'authentication',
|
|
45
|
+
type: 'hidden',
|
|
46
|
+
default: 'body',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.MicrosoftGraphOAuth2Api = MicrosoftGraphOAuth2Api;
|
|
52
|
+
//# sourceMappingURL=MicrosoftGraphOAuth2Api.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MicrosoftGraphOAuth2Api.credentials.js","sourceRoot":"","sources":["../../credentials/MicrosoftGraphOAuth2Api.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,uBAAuB;IAApC;QACC,SAAI,GAAG,yBAAyB,CAAC;QAEjC,YAAO,GAAG,CAAC,WAAW,CAAC,CAAC;QAExB,gBAAW,GAAG,4BAA4B,CAAC;QAE3C,qBAAgB,GAAG,qDAAqD,CAAC;QAEzE,SAAI,GAAG,0BAAmC,CAAC;QAE3C,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,mBAAmB;aAC5B;YACD;gBACC,WAAW,EAAE,mBAAmB;gBAChC,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,gEAAgE;aACzE;YACD;gBACC,WAAW,EAAE,kBAAkB;gBAC/B,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,4DAA4D;aACrE;YACD;gBACC,WAAW,EAAE,OAAO;gBACpB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,+DAA+D;aACxE;YACD;gBACC,WAAW,EAAE,2BAA2B;gBACxC,IAAI,EAAE,qBAAqB;gBAC3B,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,qBAAqB;aAC9B;YACD;gBACC,WAAW,EAAE,gBAAgB;gBAC7B,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,MAAM;aACf;SACD,CAAC;IACH,CAAC;CAAA;AAjDD,0DAiDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 23"><path fill="#f3f3f3" d="M0 0h23v23H0z"/><path fill="#f35325" d="M1 1h10v10H1z"/><path fill="#81bc06" d="M12 1h10v10H12z"/><path fill="#05a6f0" d="M1 12h10v10H1z"/><path fill="#ffba08" d="M12 12h10v10H12z"/></svg>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
import { searchSites, getDrives, getFiles, getSheets, getTables } from './listSearch';
|
|
3
|
+
export declare class SharePointExcel implements INodeType {
|
|
4
|
+
description: INodeTypeDescription;
|
|
5
|
+
methods: {
|
|
6
|
+
listSearch: {
|
|
7
|
+
searchSites: typeof searchSites;
|
|
8
|
+
getDrives: typeof getDrives;
|
|
9
|
+
getFiles: typeof getFiles;
|
|
10
|
+
getSheets: typeof getSheets;
|
|
11
|
+
getTables: typeof getTables;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharePointExcel = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const router_1 = require("./actions/router");
|
|
6
|
+
const descriptions_1 = require("./descriptions");
|
|
7
|
+
const listSearch_1 = require("./listSearch");
|
|
8
|
+
class SharePointExcel {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.description = {
|
|
11
|
+
displayName: 'Microsoft SharePoint Excel',
|
|
12
|
+
name: 'sharePointExcel',
|
|
13
|
+
icon: 'file:excel.svg',
|
|
14
|
+
group: ['transform'],
|
|
15
|
+
version: 1,
|
|
16
|
+
subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
|
|
17
|
+
description: 'Read and write Excel files in SharePoint (bypasses WAC token issues).',
|
|
18
|
+
defaults: {
|
|
19
|
+
name: 'Microsoft SharePoint Excel',
|
|
20
|
+
},
|
|
21
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
22
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
23
|
+
usableAsTool: true,
|
|
24
|
+
credentials: [
|
|
25
|
+
{
|
|
26
|
+
name: 'microsoftGraphOAuth2Api',
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
properties: descriptions_1.properties,
|
|
31
|
+
};
|
|
32
|
+
this.methods = {
|
|
33
|
+
listSearch: {
|
|
34
|
+
searchSites: listSearch_1.searchSites,
|
|
35
|
+
getDrives: listSearch_1.getDrives,
|
|
36
|
+
getFiles: listSearch_1.getFiles,
|
|
37
|
+
getSheets: listSearch_1.getSheets,
|
|
38
|
+
getTables: listSearch_1.getTables,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async execute() {
|
|
43
|
+
const items = this.getInputData();
|
|
44
|
+
let returnData = [];
|
|
45
|
+
try {
|
|
46
|
+
returnData = await router_1.router.call(this, items);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (err instanceof n8n_workflow_1.NodeOperationError) {
|
|
50
|
+
if (this.continueOnFail()) {
|
|
51
|
+
returnData.push({
|
|
52
|
+
json: { error: err.message },
|
|
53
|
+
pairedItem: { item: 0 },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const error = err;
|
|
62
|
+
if (this.continueOnFail()) {
|
|
63
|
+
returnData.push({
|
|
64
|
+
json: { error: error.message },
|
|
65
|
+
pairedItem: { item: 0 },
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.message);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return [returnData];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.SharePointExcel = SharePointExcel;
|
|
77
|
+
//# sourceMappingURL=SharePointExcel.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharePointExcel.node.js","sourceRoot":"","sources":["../../../nodes/SharePointExcel/SharePointExcel.node.ts"],"names":[],"mappings":";;;AAMA,+CAAuE;AACvE,6CAA0C;AAC1C,iDAA4C;AAC5C,6CAMsB;AAEtB,MAAa,eAAe;IAA5B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,4BAA4B;YACzC,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EACV,uEAAuE;YACxE,QAAQ,EAAE;gBACT,IAAI,EAAE,4BAA4B;aAClC;YACD,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,yBAAyB;oBAC/B,QAAQ,EAAE,IAAI;iBACd;aACD;YACD,UAAU,EAAV,yBAAU;SACV,CAAC;QAEF,YAAO,GAAG;YACT,UAAU,EAAE;gBACX,WAAW,EAAX,wBAAW;gBACX,SAAS,EAAT,sBAAS;gBACT,QAAQ,EAAR,qBAAQ;gBACR,SAAS,EAAT,sBAAS;gBACT,SAAS,EAAT,sBAAS;aACT;SACD,CAAC;IAkCH,CAAC;IAhCA,KAAK,CAAC,OAAO;QACZ,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAClC,IAAI,UAAU,GAAyB,EAAE,CAAC;QAE1C,IAAI,CAAC;YACJ,UAAU,GAAG,MAAM,eAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YAEd,IAAI,GAAG,YAAY,iCAAkB,EAAE,CAAC;gBACvC,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC3B,UAAU,CAAC,IAAI,CAAC;wBACf,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE;wBAC5B,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;qBACvB,CAAC,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACP,MAAM,GAAG,CAAC;gBACX,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,MAAM,KAAK,GAAG,GAAY,CAAC;gBAC3B,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC3B,UAAU,CAAC,IAAI,CAAC;wBACf,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE;wBAC9B,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;qBACvB,CAAC,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACP,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC7D,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AAnED,0CAmEC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
import type { OperationContext } from '../types';
|
|
3
|
+
export declare function buildContext(executeFunctions: IExecuteFunctions): OperationContext;
|
|
4
|
+
export declare function router(this: IExecuteFunctions, items: INodeExecutionData[]): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.buildContext = buildContext;
|
|
37
|
+
exports.router = router;
|
|
38
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
39
|
+
const sheet = __importStar(require("./sheet"));
|
|
40
|
+
const workbook = __importStar(require("./workbook"));
|
|
41
|
+
const table = __importStar(require("./table"));
|
|
42
|
+
function buildContext(executeFunctions) {
|
|
43
|
+
const source = 'sharepoint';
|
|
44
|
+
const resource = executeFunctions.getNodeParameter('resource', 0);
|
|
45
|
+
const operation = executeFunctions.getNodeParameter('operation', 0);
|
|
46
|
+
const driveIdParam = executeFunctions.getNodeParameter('driveId', 0);
|
|
47
|
+
const driveId = typeof driveIdParam === 'object' ? driveIdParam.value : driveIdParam;
|
|
48
|
+
const fileIdParam = executeFunctions.getNodeParameter('fileId', 0);
|
|
49
|
+
const fileId = typeof fileIdParam === 'object' ? fileIdParam.value : fileIdParam;
|
|
50
|
+
const siteIdParam = executeFunctions.getNodeParameter('siteId', 0);
|
|
51
|
+
const siteId = typeof siteIdParam === 'object' ? siteIdParam.value : siteIdParam;
|
|
52
|
+
const basePath = `/sites/${siteId}/drives/${driveId}/items/${fileId}`;
|
|
53
|
+
return {
|
|
54
|
+
source,
|
|
55
|
+
resource,
|
|
56
|
+
operation,
|
|
57
|
+
basePath,
|
|
58
|
+
driveId,
|
|
59
|
+
fileId,
|
|
60
|
+
siteId,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async function router(items) {
|
|
64
|
+
const context = buildContext(this);
|
|
65
|
+
const { resource, operation } = context;
|
|
66
|
+
if (resource === 'sheet') {
|
|
67
|
+
switch (operation) {
|
|
68
|
+
case 'getSheets':
|
|
69
|
+
return sheet.getSheets.execute.call(this, items, context);
|
|
70
|
+
case 'readRows':
|
|
71
|
+
return sheet.readRows.execute.call(this, items, context);
|
|
72
|
+
case 'appendRows':
|
|
73
|
+
return sheet.appendRows.execute.call(this, items, context);
|
|
74
|
+
case 'updateCell':
|
|
75
|
+
return sheet.updateRange.execute.call(this, items, context);
|
|
76
|
+
case 'upsertRows':
|
|
77
|
+
return sheet.upsertRows.execute.call(this, items, context);
|
|
78
|
+
case 'clearSheet':
|
|
79
|
+
return sheet.clearSheet.execute.call(this, items, context);
|
|
80
|
+
case 'deleteSheet':
|
|
81
|
+
return sheet.deleteSheet.execute.call(this, items, context);
|
|
82
|
+
default:
|
|
83
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown sheet operation: ${operation}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (resource === 'table') {
|
|
87
|
+
switch (operation) {
|
|
88
|
+
case 'getColumns':
|
|
89
|
+
return table.getColumns.execute.call(this, items, context);
|
|
90
|
+
case 'getTableRows':
|
|
91
|
+
return table.getRows.execute.call(this, items, context);
|
|
92
|
+
case 'lookup':
|
|
93
|
+
return table.lookup.execute.call(this, items, context);
|
|
94
|
+
default:
|
|
95
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown table operation: ${operation}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (resource === 'workbook') {
|
|
99
|
+
switch (operation) {
|
|
100
|
+
case 'getWorkbookSheets':
|
|
101
|
+
return workbook.getSheets.execute.call(this, items, context);
|
|
102
|
+
case 'addSheet':
|
|
103
|
+
return workbook.addSheet.execute.call(this, items, context);
|
|
104
|
+
case 'deleteWorkbook':
|
|
105
|
+
return workbook.deleteWorkbook.execute.call(this, items, context);
|
|
106
|
+
case 'getWorkbooks':
|
|
107
|
+
return workbook.getWorkbooks.execute.call(this, items, context);
|
|
108
|
+
default:
|
|
109
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown workbook operation: ${operation}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown resource: ${resource}`);
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../nodes/SharePointExcel/actions/router.ts"],"names":[],"mappings":";;;;;;;;;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B,QAAQ,EAAE,CAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
import type { OperationContext } from '../../types';
|
|
3
|
+
export declare function execute(this: IExecuteFunctions, items: INodeExecutionData[], context: OperationContext): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute = execute;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const api_1 = require("../../api");
|
|
6
|
+
async function execute(items, context) {
|
|
7
|
+
const returnData = [];
|
|
8
|
+
const sheetNameParam = this.getNodeParameter('sheetName', 0);
|
|
9
|
+
const sheetName = typeof sheetNameParam === 'object' ? sheetNameParam.value : sheetNameParam;
|
|
10
|
+
for (let i = 0; i < items.length; i++) {
|
|
11
|
+
const rowDataParam = this.getNodeParameter('rowData', i);
|
|
12
|
+
let rowsToAdd;
|
|
13
|
+
try {
|
|
14
|
+
const parsed = JSON.parse(rowDataParam);
|
|
15
|
+
rowsToAdd = Array.isArray(parsed) ? parsed : [parsed];
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON in Row Data: ${err.message}`, { itemIndex: i });
|
|
19
|
+
}
|
|
20
|
+
const workbook = await api_1.loadWorkbook.call(this, context.basePath);
|
|
21
|
+
const worksheet = (0, api_1.getWorksheet)(workbook, sheetName, this, i);
|
|
22
|
+
const headers = [];
|
|
23
|
+
const headerRow = worksheet.getRow(1);
|
|
24
|
+
headerRow.eachCell({ includeEmpty: false }, (cell, colNumber) => {
|
|
25
|
+
headers[colNumber] = String(cell.value);
|
|
26
|
+
});
|
|
27
|
+
const hasHeaders = headers.some((h) => h && h.trim() !== '');
|
|
28
|
+
const headerMap = {};
|
|
29
|
+
if (!hasHeaders && rowsToAdd.length > 0) {
|
|
30
|
+
const keys = Object.keys(rowsToAdd[0]);
|
|
31
|
+
keys.forEach((key, idx) => {
|
|
32
|
+
const colNumber = idx + 1;
|
|
33
|
+
headerRow.getCell(colNumber).value = key;
|
|
34
|
+
headers[colNumber] = key;
|
|
35
|
+
headerMap[key] = colNumber;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
headers.forEach((h, idx) => {
|
|
40
|
+
if (h)
|
|
41
|
+
headerMap[h] = idx;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
for (const rowData of rowsToAdd) {
|
|
45
|
+
const newRow = [];
|
|
46
|
+
for (const [key, value] of Object.entries(rowData)) {
|
|
47
|
+
const colIdx = headerMap[key];
|
|
48
|
+
if (colIdx !== undefined) {
|
|
49
|
+
newRow[colIdx] = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
worksheet.addRow(newRow);
|
|
53
|
+
}
|
|
54
|
+
await api_1.saveWorkbook.call(this, context.basePath, workbook);
|
|
55
|
+
returnData.push({
|
|
56
|
+
json: {
|
|
57
|
+
success: true,
|
|
58
|
+
rowsAdded: rowsToAdd.length,
|
|
59
|
+
sheet: sheetName,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return returnData;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=appendRows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appendRows.js","sourceRoot":"","sources":["../../../../../nodes/SharePointExcel/actions/sheet/appendRows.ts"],"names":[],"mappings":";;AAKA,0BAqFC;AAzFD,+CAAkD;AAClD,mCAAqE;AAG9D,KAAK,UAAU,OAAO,CAE5B,KAA2B,EAC3B,OAAyB;IAEzB,MAAM,UAAU,GAAyB,EAAE,CAAC;IAE5C,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAEpC,C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AC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;QAGD,MAAM,kBAAY,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAE1D,UAAU,CAAC,IAAI,CAAC;YACf,IAAI,EAAE;gBACL,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,SAAS,CAAC,MAAM;gBAC3B,KAAK,EAAE,SAAS;aACD;SAChB,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
import type { OperationContext } from '../../types';
|
|
3
|
+
export declare function execute(this: IExecuteFunctions, _items: INodeExecutionData[], context: OperationContext): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute = execute;
|
|
4
|
+
const api_1 = require("../../api");
|
|
5
|
+
async function execute(_items, context) {
|
|
6
|
+
const sheetNameParam = this.getNodeParameter('sheetName', 0);
|
|
7
|
+
const sheetName = typeof sheetNameParam === 'object' ? sheetNameParam.value : sheetNameParam;
|
|
8
|
+
const workbook = await api_1.loadWorkbook.call(this, context.basePath);
|
|
9
|
+
const worksheet = (0, api_1.getWorksheet)(workbook, sheetName, this);
|
|
10
|
+
const rowCount = worksheet.rowCount;
|
|
11
|
+
const columnCount = worksheet.columnCount;
|
|
12
|
+
for (let i = worksheet.rowCount; i >= 1; i--) {
|
|
13
|
+
worksheet.spliceRows(i, 1);
|
|
14
|
+
}
|
|
15
|
+
await api_1.saveWorkbook.call(this, context.basePath, workbook);
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
json: {
|
|
19
|
+
success: true,
|
|
20
|
+
sheet: sheetName,
|
|
21
|
+
clearedRows: rowCount,
|
|
22
|
+
clearedColumns: columnCount,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=clearSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clearSheet.js","sourceRoot":"","sources":["../../../../../nodes/SharePointExcel/actions/sheet/clearSheet.ts"],"names":[],"mappings":";;AAIA,0BAoCC;AAvCD,mCAAqE;AAG9D,KAAK,UAAU,OAAO,CAE5B,MAA4B,EAC5B,OAAyB;IAEzB,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAEpC,CAAC;IACxB,MAAM,SAAS,GACd,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC;IAE5E,MAAM,QAAQ,GAAG,MAAM,kBAAY,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjE,MAAM,SAAS,GAAG,IAAA,kBAAY,EAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAG1D,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpC,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;IAG1C,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5B,CAAC;IAGD,MAAM,kBAAY,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAE1D,OAAO;QACN;YACC,IAAI,EAAE;gBACL,OAAO,EAAE,IAAI;gBACb,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,QAAQ;gBACrB,cAAc,EAAE,WAAW;aACZ;SAChB;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
import type { OperationContext } from '../../types';
|
|
3
|
+
export declare function execute(this: IExecuteFunctions, _items: INodeExecutionData[], context: OperationContext): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute = execute;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const api_1 = require("../../api");
|
|
6
|
+
async function execute(_items, context) {
|
|
7
|
+
const sheetNameParam = this.getNodeParameter('sheetName', 0);
|
|
8
|
+
const sheetName = typeof sheetNameParam === 'object' ? sheetNameParam.value : sheetNameParam;
|
|
9
|
+
const workbook = await api_1.loadWorkbook.call(this, context.basePath);
|
|
10
|
+
const worksheet = workbook.getWorksheet(sheetName);
|
|
11
|
+
if (!worksheet) {
|
|
12
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Sheet "${sheetName}" not found in workbook`);
|
|
13
|
+
}
|
|
14
|
+
if (workbook.worksheets.length <= 1) {
|
|
15
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Cannot delete the last sheet in a workbook');
|
|
16
|
+
}
|
|
17
|
+
workbook.removeWorksheet(worksheet.id);
|
|
18
|
+
await api_1.saveWorkbook.call(this, context.basePath, workbook);
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
json: {
|
|
22
|
+
success: true,
|
|
23
|
+
deletedSheet: sheetName,
|
|
24
|
+
remainingSheets: workbook.worksheets.map((ws) => ws.name),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=deleteSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteSheet.js","sourceRoot":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0,0 +1,3 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
import type { OperationContext } from '../../types';
|
|
3
|
+
export declare function execute(this: IExecuteFunctions, _items: INodeExecutionData[], context: OperationContext): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute = execute;
|
|
4
|
+
const api_1 = require("../../api");
|
|
5
|
+
async function execute(_items, context) {
|
|
6
|
+
const workbook = await api_1.loadWorkbook.call(this, context.basePath);
|
|
7
|
+
const sheets = workbook.worksheets.map((ws) => ({
|
|
8
|
+
name: ws.name,
|
|
9
|
+
id: ws.id,
|
|
10
|
+
rowCount: ws.rowCount,
|
|
11
|
+
columnCount: ws.columnCount,
|
|
12
|
+
}));
|
|
13
|
+
return [{ json: { sheets } }];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=getSheets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSheets.js","sourceRoot":"","sources":["../../../../../nodes/SharePointExcel/actions/sheet/getSheets.ts"],"names":[],"mappings":";;AAIA,0BAeC;AAlBD,mCAAyC;AAGlC,KAAK,UAAU,OAAO,CAE5B,MAA4B,EAC5B,OAAyB;IAEzB,MAAM,QAAQ,GAAG,MAAM,kBAAY,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjE,MAAM,MAAM,GAAgB,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5D,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,EAAE,EAAE,EAAE,CAAC,EAAE;QACT,QAAQ,EAAE,EAAE,CAAC,QAAQ;QACrB,WAAW,EAAE,EAAE,CAAC,WAAW;KAC3B,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as getSheets from './getSheets';
|
|
2
|
+
import * as readRows from './readRows';
|
|
3
|
+
import * as appendRows from './appendRows';
|
|
4
|
+
import * as updateRange from './updateRange';
|
|
5
|
+
import * as upsertRows from './upsertRows';
|
|
6
|
+
import * as clearSheet from './clearSheet';
|
|
7
|
+
import * as deleteSheet from './deleteSheet';
|
|
8
|
+
export { getSheets, readRows, appendRows, updateRange, upsertRows, clearSheet, deleteSheet, };
|