-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Microsoft Excel - Updates and New Components #16369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
75da6d2
wip
michelle0927 82900f8
updates & new components
michelle0927 7bb53a0
pnpm-lock.yaml
michelle0927 e7e84dd
fix column prop
michelle0927 cbd7547
updates
michelle0927 23a592f
pnpm-lock.yaml
michelle0927 34f70d4
pnpm-lock.yaml
michelle0927 e2be690
Update components/microsoft_excel/sources/common/base-webhook.mjs
michelle0927 2b3c47c
fix
michelle0927 aa811fa
updates
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import microsoftExcel from "../../microsoft_excel.app.mjs"; | ||
| import { | ||
| parseObject, getColumnLetter, | ||
| } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "microsoft_excel-add-row", | ||
| name: "Add Row", | ||
| description: "Insert a new row into a specified Excel worksheet. [See the documentation](https://learn.microsoft.com/en-us/graph/api/range-insert?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, | ||
| }), | ||
| ], | ||
| }, | ||
| values: { | ||
| type: "string[]", | ||
| label: "Values", | ||
| description: "An array of values for the new row. Each item in the array represents one cell. E.g. `[1, 2, 3]`", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| address, columnCount, | ||
| } = await this.microsoftExcel.getUsedRange({ | ||
| $, | ||
| sheetId: this.sheetId, | ||
| worksheet: this.worksheet, | ||
| }); | ||
|
|
||
| // get next row range | ||
| const match = address.match(/^(.+!)?([A-Z]+)(\d+):([A-Z]+)(\d+)$/); | ||
| const nextRow = parseInt(match[5], 10) + 1; | ||
| const values = parseObject(this.values); | ||
| if (values.length < columnCount) { | ||
| values.length = columnCount; | ||
| } | ||
| const colEnd = getColumnLetter(values.length); | ||
| const range = `A${nextRow}:${colEnd}${nextRow}`; | ||
|
|
||
| // insert range | ||
| await this.microsoftExcel.insertRange({ | ||
| $, | ||
| sheetId: this.sheetId, | ||
| worksheet: this.worksheet, | ||
| range, | ||
| data: { | ||
| shift: "Down", | ||
| }, | ||
| }); | ||
|
|
||
| // update range | ||
| const response = await this.microsoftExcel.updateRange({ | ||
| $, | ||
| sheetId: this.sheetId, | ||
| worksheet: this.worksheet, | ||
| range, | ||
| data: { | ||
| values: [ | ||
| values, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", "Successfully added new row"); | ||
| return response; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import microsoftExcel from "../../microsoft_excel.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "microsoft_excel-find-row", | ||
| name: "Find Row", | ||
| description: "Find a row by column and value in an 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, | ||
| }), | ||
| ], | ||
| }, | ||
| column: { | ||
| type: "string", | ||
| label: "Column", | ||
| description: "The column to search. E.g. `A`", | ||
| }, | ||
| value: { | ||
| type: "string", | ||
| label: "Value", | ||
| description: "The value to search for. For non-string values, use a custom expression. For example: `{{ 1 }}` for the numeric value 1", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| rowCount, address, | ||
| } = await this.microsoftExcel.getUsedRange({ | ||
| $, | ||
| sheetId: this.sheetId, | ||
| worksheet: this.worksheet, | ||
| }); | ||
| const lastColumn = address.match(/:([A-Z]+)\d+$/)[1]; | ||
|
|
||
| const { values: rangeValues } = await this.microsoftExcel.getRange({ | ||
| $, | ||
| sheetId: this.sheetId, | ||
| worksheet: this.worksheet, | ||
| range: `${this.column}1:${this.column}${rowCount}`, | ||
| }); | ||
| const values = rangeValues.map((v) => v[0]); | ||
| const index = values.indexOf(this.value); | ||
|
|
||
| if (index === -1) { | ||
| $.export("$summary", "No matching rows found"); | ||
| return values; | ||
| } | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const row = index + 1; | ||
| const response = await this.microsoftExcel.getRange({ | ||
| $, | ||
| sheetId: this.sheetId, | ||
| worksheet: this.worksheet, | ||
| range: `A${row}:${lastColumn}${row}`, | ||
| }); | ||
|
|
||
| $.export("$summary", `Found value in row ${row}`); | ||
| return response; | ||
| }, | ||
| }; | ||
65 changes: 65 additions & 0 deletions
65
components/microsoft_excel/actions/get-columns/get-columns.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import microsoftExcel from "../../microsoft_excel.app.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "microsoft_excel-get-columns", | ||
| name: "Get Columns", | ||
| description: "Get the values of the specified columns in an 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, | ||
| }), | ||
| ], | ||
| }, | ||
| columns: { | ||
| type: "string[]", | ||
| label: "Columns", | ||
| description: "An array of column labels to retrieve. E.g. [\"A\", \"C\"]", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { rowCount } = await this.microsoftExcel.getUsedRange({ | ||
| $, | ||
| sheetId: this.sheetId, | ||
| worksheet: this.worksheet, | ||
| }); | ||
|
|
||
| const values = {}; | ||
| const columns = parseObject(this.columns); | ||
| for (const column of columns) { | ||
| const response = await this.microsoftExcel.getRange({ | ||
| $, | ||
| sheetId: this.sheetId, | ||
| worksheet: this.worksheet, | ||
| range: `${column}1:${column}${rowCount}`, | ||
| }); | ||
| values[column] = response.values.map((v) => v[0]); | ||
| } | ||
|
|
||
| $.export("$summary", "Successfully retrieved column values"); | ||
|
|
||
| return values; | ||
| }, | ||
| }; |
63 changes: 63 additions & 0 deletions
63
components/microsoft_excel/actions/get-spreadsheet/get-spreadsheet.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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; | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.