-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathget-spreadsheet.mjs
63 lines (60 loc) · 1.57 KB
/
get-spreadsheet.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import microsoftExcel from "../../microsoft_excel.app.mjs";
import { json2csv } from "json-2-csv";
export default {
key: "microsoft_excel-get-spreadsheet",
name: "Get Spreadsheet",
description: "Get the values of a specified Excel worksheet. [See the documentation](https://learn.microsoft.com/en-us/graph/api/range-get?view=graph-rest-1.0&tabs=http)",
version: "0.0.1",
type: "action",
props: {
microsoftExcel,
folderId: {
propDefinition: [
microsoftExcel,
"folderId",
],
},
sheetId: {
propDefinition: [
microsoftExcel,
"sheetId",
({ folderId }) => ({
folderId,
}),
],
},
worksheet: {
propDefinition: [
microsoftExcel,
"worksheet",
({ sheetId }) => ({
sheetId,
}),
],
},
range: {
type: "string",
label: "Range",
description: "The range within the worksheet to retrieve. E.g. `A1:C4`. If not specified, entire \"usedRange\" will be returned",
optional: true,
},
},
async run({ $ }) {
const response = this.range
? await this.microsoftExcel.getRange({
$,
sheetId: this.sheetId,
worksheet: this.worksheet,
range: `${this.range}`,
})
: await this.microsoftExcel.getUsedRange({
$,
sheetId: this.sheetId,
worksheet: this.worksheet,
});
const csv = await json2csv(response.values);
response.csv = csv;
$.export("$summary", "Successfully retrieved spreadsheet values");
return response;
},
};