├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── 1_documentation-issue.md │ ├── 2_sample-request.md │ └── 3_customer-feedback.yml ├── policies │ └── resourceManagement.yml └── workflows │ └── auto-publish.yml ├── .gitignore ├── .openpublishing.publish.config.json ├── .openpublishing.redirection.json ├── Contributing.md ├── LICENSE ├── LICENSE-CODE ├── README.md ├── SECURITY.md ├── ThirdPartyNotices.md ├── docs ├── breadcrumb │ └── toc.yml ├── develop │ ├── best-practices.md │ ├── external-calls.md │ ├── javascript-objects.md │ ├── macros-power-automate.md │ ├── pivottable-sample.xlsx │ ├── pivottables.md │ ├── power-automate-integration.md │ ├── power-automate-parameters-returns.md │ ├── script-buttons.md │ ├── scripting-fundamentals.md │ ├── typescript-restrictions.md │ ├── use-json.md │ ├── user-input.md │ └── web-client-performance.md ├── docfx.json ├── images │ ├── action-recorder-copy-code.png │ ├── action-recorder-intro.png │ ├── add-button.png │ ├── after-filter-cleared.png │ ├── all-files-in-folder-sample-flow-1.PNG │ ├── all-files-in-folder-sample-flow-2.PNG │ ├── all-files-in-folder-sample-flow-3.PNG │ ├── all-files-in-folder-sample-flow-4.png │ ├── audit-log-example.png │ ├── automate-a-task-button.png │ ├── automate-a-task-choices.png │ ├── before-filter-applied.png │ ├── blank-rows.png │ ├── chart-created.png │ ├── chart-sample.png │ ├── code-editor-feedback.png │ ├── code-editor-intro.png │ ├── combine-worksheets-flow-1.PNG │ ├── combine-worksheets-flow-2.PNG │ ├── combine-worksheets-flow-3.PNG │ ├── combine-worksheets-flow-4.PNG │ ├── combine-worksheets-flow-5.PNG │ ├── combine-worksheets-flow-workbook-name-shorten-flow.png │ ├── combine-worksheets-flow-workbook-name-shorten.png │ ├── conditional-formatting-sample-cell-value.png │ ├── conditional-formatting-sample-color-scale.png │ ├── conditional-formatting-sample-custom.png │ ├── conditional-formatting-sample-data-bar.png │ ├── conditional-formatting-sample-icon-set.png │ ├── conditional-formatting-sample-preset.png │ ├── conditional-formatting-sample-text-comparison.png │ ├── conditional-formatting-sample-top-bottom.png │ ├── convert-csv-flow-1.png │ ├── convert-csv-flow-2.png │ ├── convert-csv-flow-3.png │ ├── convert-csv-flow-4.png │ ├── convert-csv-flow-5.png │ ├── convert-csv-flow-6.png │ ├── convert-csv-flow-7.png │ ├── create-json-console-output.png │ ├── cross-reference-flow-1.PNG │ ├── cross-reference-flow-2.PNG │ ├── cross-reference-flow-3.PNG │ ├── cross-reference-flow-4.png │ ├── data-validation-error.png │ ├── data-validation-prompt.png │ ├── day-to-day-changes-flow-1.png │ ├── day-to-day-changes-flow-2.png │ ├── day-to-day-changes-flow-3.png │ ├── day-to-day-changes-flow-4.png │ ├── email-chart-sample-flow-1.PNG │ ├── email-chart-sample-flow-2.PNG │ ├── email-received.png │ ├── explicit-any-editor-message.png │ ├── explicit-any-error-message.png │ ├── git-octocat.png │ ├── git.png │ ├── implicit-any-editor-message.png │ ├── index-landing-page │ │ ├── i_architecture.svg │ │ ├── i_article.svg │ │ ├── i_bug.svg │ │ ├── i_code-blocks.svg │ │ ├── i_code-samples.svg │ │ ├── i_feedback.svg │ │ ├── i_get-started.svg │ │ ├── i_library.svg │ │ ├── i_reference.svg │ │ ├── i_share.svg │ │ ├── i_support.svg │ │ └── i_upgrade.svg │ ├── input-data.png │ ├── json-parameter-power-automate.png │ ├── load-sync.png │ ├── load-sync.vsdx │ ├── no-blank-rows.png │ ├── office-programmability-diagram.png │ ├── office-programmability-diagram.pptx │ ├── outlook-connector-settings.png │ ├── pivottable-data-hierarchy.png │ ├── pivottable-empty.png │ ├── pivottable-filter-hierarchy.png │ ├── pivottable-filters.png │ ├── pivottable-layout-breakdown.png │ ├── pivottable-object-model.png │ ├── pivottable-object-model.vsdx │ ├── pivottable-raw-data.png │ ├── power-automate-default-parameter.png │ ├── power-automate-drop-down-parameter-choices.png │ ├── power-automate-file-browser.PNG │ ├── power-automate-parameter-return-sample.png │ ├── power-automate-params-tutorial-1.png │ ├── power-automate-params-tutorial-2.png │ ├── power-automate-params-tutorial-3.png │ ├── power-automate-params-tutorial-4.png │ ├── power-automate-params-tutorial-5.png │ ├── power-automate-return-dynamic-content.png │ ├── power-automate-return-tutorial-1.PNG │ ├── power-automate-return-tutorial-2.PNG │ ├── power-automate-return-tutorial-3.PNG │ ├── power-automate-return-tutorial-4.PNG │ ├── power-automate-return-tutorial-5.PNG │ ├── power-automate-return-tutorial-6.PNG │ ├── power-automate-return-tutorial-7.PNG │ ├── power-automate-tutorial-1.png │ ├── power-automate-tutorial-10.png │ ├── power-automate-tutorial-2.png │ ├── power-automate-tutorial-3.png │ ├── power-automate-tutorial-4.png │ ├── power-automate-tutorial-5.png │ ├── power-automate-tutorial-6.png │ ├── power-automate-tutorial-7.png │ ├── power-automate-tutorial-8.png │ ├── power-automate-tutorial-9.png │ ├── power-query-flow-option.PNG │ ├── punch-clock-sample-1.png │ ├── punch-clock-sample-2.png │ ├── range-sample.png │ ├── reference-documentation-version-picker.png │ ├── remove-button.png │ ├── run-from-button.png │ ├── run-script-from-sp-library.png │ ├── run-script.png │ ├── runtime-error-console.png │ ├── sample-data-validation.png │ ├── sample-pivottable-grand-total-row.png │ ├── scenario-analyze-web-downloads-after.png │ ├── scenario-analyze-web-downloads-before.png │ ├── scenario-analyze-web-downloads-table.png │ ├── scenario-grade-calculator-after.png │ ├── scenario-grade-calculator-before.png │ ├── scenario-noaa-water-level-after.PNG │ ├── scenario-task-reminders-1.png │ ├── scenario-task-reminders-2.png │ ├── scenario-task-reminders-3.png │ ├── scenario-task-reminders-4.png │ ├── scenario-task-reminders-adaptive-card.png │ ├── scenario-task-reminders-spreadsheet-after.png │ ├── scenario-task-reminders-spreadsheet-before.png │ ├── schedule-a-script.png │ ├── schedule-interviews-1.png │ ├── schedule-interviews-2.png │ ├── schedule-interviews-3.png │ ├── schedule-interviews-4.png │ ├── script-sharing.png │ ├── slicer.png │ ├── table-hyperlink-view.png │ ├── table-input.png │ ├── table-of-contents-sample.png │ ├── table-sample.PNG │ ├── teaser-animation.gif │ ├── tutorial-1.png │ ├── tutorial-2.png │ ├── tutorial-3.png │ ├── tutorial-4.png │ ├── tutorial-5.png │ ├── user-input-example.png │ ├── write-large-dataset-1.png │ ├── write-large-dataset-2.png │ ├── write-large-dataset-3.png │ ├── write-large-dataset-4.png │ ├── write-large-dataset-5.png │ ├── write-large-dataset-6.png │ ├── write-large-dataset-7.png │ ├── write-large-dataset-8.png │ └── write-large-dataset-9.png ├── includes │ ├── coding-basics-references.md │ ├── external-calls-power-automate.md │ ├── platform-requirements.md │ ├── platform-support-table.md │ ├── power-automate-needs-business.md │ ├── power-automate-tutorial-prerequisites.md │ ├── teams-support-note.md │ └── tutorial-prerequisites.md ├── index.yml ├── overview │ ├── code-editor-environment.md │ ├── excel.md │ └── script-storage.md ├── resources │ ├── add-ins-differences.md │ ├── power-query-differences.md │ ├── samples │ │ ├── add-excel-comments.md │ │ ├── add-excel-comments.xlsx │ │ ├── add-image-to-workbook.md │ │ ├── add-images.xlsx │ │ ├── automate-tasks-on-all-excel-files-in-folder.md │ │ ├── combine-worksheets-into-single-workbook.md │ │ ├── community-seasons-greetings.md │ │ ├── conditional-formatting-parameters.md │ │ ├── conditional-formatting-samples.md │ │ ├── conditional-formatting-samples.xlsx │ │ ├── convert-csv-example.zip │ │ ├── convert-csv.md │ │ ├── copy-tables-combine.md │ │ ├── count-blank-rows.md │ │ ├── daily-readings.xlsx │ │ ├── data-validation-samples.md │ │ ├── email-chart-table.xlsx │ │ ├── email-images-chart-table.md │ │ ├── event-data.xlsx │ │ ├── excel-calculation.md │ │ ├── excel-cross-reference.md │ │ ├── external-fetch-calls.md │ │ ├── get-table-data.md │ │ ├── happy-tree.xlsx │ │ ├── highlight-alert-excel-files.zip │ │ ├── input-table-filters.xlsx │ │ ├── javascript-dates.md │ │ ├── move-rows-across-tables.md │ │ ├── range-samples.md │ │ ├── remove-hyperlinks-from-cells.md │ │ ├── remove-hyperlinks.xlsx │ │ ├── report-day-to-day-changes.md │ │ ├── row-and-column-visibility.md │ │ ├── samples-overview.md │ │ ├── speaker-registrations.xlsx │ │ ├── table-data-with-hyperlinks.xlsx │ │ ├── table-of-contents.md │ │ ├── table-of-contents.xlsx │ │ ├── table-samples.md │ │ ├── table-with-filter.xlsx │ │ ├── tables-copy.xlsx │ │ ├── tables-select-copy.xlsx │ │ └── write-large-dataset.md │ ├── scenarios │ │ ├── analyze-web-downloads.md │ │ ├── analyze-web-downloads.xlsx │ │ ├── grade-calculator.md │ │ ├── grade-calculator.xlsx │ │ ├── hr-schedule.xlsx │ │ ├── noaa-data-fetch.md │ │ ├── punch-clock-sample.xlsx │ │ ├── punch-clock.md │ │ ├── schedule-interviews-in-teams.md │ │ ├── task-reminders.md │ │ └── task-reminders.xlsx │ └── vba-differences.md ├── testing │ ├── platform-limits.md │ ├── power-automate-troubleshooting.md │ ├── troubleshooting.md │ └── undo.md ├── toc.yml └── tutorials │ ├── excel-power-automate-manual.md │ ├── excel-power-automate-returns.md │ ├── excel-power-automate-trigger.md │ ├── excel-read-tutorial.md │ ├── excel-tutorial.md │ └── on-call-rotation.xlsx └── licensing-information.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.c text 7 | *.h text 8 | 9 | # Declare files that will always have CRLF line endings on checkout. 10 | *.sln text eol=crlf 11 | 12 | # Denote all files that are truly binary and should not be modified. 13 | *.png binary 14 | *.jpg binary -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/1_documentation-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation issue 3 | about: Tell us about a problem in the documentation 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Article URL** 11 | 12 | 13 | **Describe the problem** 14 | 15 | 16 | **Screenshots** 17 | 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/2_sample-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Sample request 3 | about: Which features would you like to see more of? 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe your scenario** 11 | 12 | 13 | **Which APIs or Excel features?** 14 | 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/3_customer-feedback.yml: -------------------------------------------------------------------------------- 1 | name: "📄 Feedback control template" 2 | title: "Feedback" 3 | description: >- 4 | ⛔ This template is intended for use by the feedback control on the bottom of every page on the 5 | live site. If you aren't using the feedback control, choose one of the other templates.⛔ 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: "## 🎁Enter your feedback🎁" 10 | - type: markdown 11 | attributes: 12 | value: Select the issue type, and describe the issue in the text box below. Add as much detail as needed to help us resolve the issue. 13 | - type: dropdown 14 | id: issue-type 15 | attributes: 16 | label: Type of issue 17 | options: 18 | - Typo 19 | - Code doesn't work 20 | - Missing information 21 | - Outdated article 22 | - Other (describe below) 23 | validations: 24 | required: true 25 | - type: textarea 26 | id: userfeedback 27 | validations: 28 | required: true 29 | attributes: 30 | label: Feedback 31 | description: >- 32 | If possible, please provide extended details that will add context and help the team update 33 | the documentation. Additional details may not be useful for typos, grammar, formatting, etc. 34 | For technical or factual errors, please include code snippets and output to show how the 35 | documentation is incorrect. 36 | - type: markdown 37 | attributes: 38 | value: "## 🚧 Article information 🚧" 39 | - type: markdown 40 | attributes: 41 | value: "*Don't modify the following fields*. They are automatically filled in for you. Doing so will disconnect your issue from the affected article. *Don't edit them*." 42 | - type: input 43 | id: pageUrl 44 | validations: 45 | required: true 46 | attributes: 47 | label: Page URL 48 | - type: input 49 | id: contentSourceUrl 50 | validations: 51 | required: true 52 | attributes: 53 | label: Content source URL 54 | - type: input 55 | id: author 56 | validations: 57 | required: true 58 | attributes: 59 | label: Author 60 | description: GitHub Id of the author 61 | - type: input 62 | id: documentVersionIndependentId 63 | validations: 64 | required: true 65 | attributes: 66 | label: Document Id 67 | - type: input 68 | id: platformId 69 | validations: 70 | required: true 71 | attributes: 72 | label: Platform Id 73 | -------------------------------------------------------------------------------- /.github/policies/resourceManagement.yml: -------------------------------------------------------------------------------- 1 | id: 2 | name: GitOps.PullRequestIssueManagement 3 | description: GitOps.PullRequestIssueManagement primitive 4 | owner: 5 | resource: repository 6 | disabled: false 7 | where: 8 | configuration: 9 | resourceManagementConfiguration: 10 | scheduledSearches: 11 | - description: 12 | frequencies: 13 | - hourly: 14 | hour: 3 15 | filters: 16 | - isIssue 17 | - isOpen 18 | - hasLabel: 19 | label: 'Needs: author feedback' 20 | - noActivitySince: 21 | days: 4 22 | - isNotLabeledWith: 23 | label: 'Status: no recent activity' 24 | actions: 25 | - addLabel: 26 | label: 'Status: no recent activity' 27 | - addReply: 28 | reply: This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**. Thank you for your interest in Office Add-ins! 29 | - description: 30 | frequencies: 31 | - hourly: 32 | hour: 3 33 | filters: 34 | - isIssue 35 | - isOpen 36 | - hasLabel: 37 | label: 'Type: programming question' 38 | actions: 39 | - addReply: 40 | reply: Thanks for your interest in Office Scripts development! Feedback here is intended for reporting problems with the Office Scripts *documentation*. Can you please post your question to Stack Overflow with the [office-scripts](https://stackoverflow.com/questions/tagged/office-scripts) tag? By posting how-to questions like this to Stack Overflow, you'll not only be able to reach a broader audience of folks who have expertise in the area, but will also enable others to benefit from any answers that are provided there. Thanks! 41 | - closeIssue 42 | - description: 43 | frequencies: 44 | - hourly: 45 | hour: 3 46 | filters: 47 | - isIssue 48 | - isOpen 49 | - hasLabel: 50 | label: 'Type: product feature request' 51 | actions: 52 | - addReply: 53 | reply: Thanks for your interest in Office Scripts development! Feedback here is intended for reporting problems with the Office Scripts *documentation*. Can you please post this feature request to the Excel Tech Community (https://techcommunity.microsoft.com/t5/excel/bd-p/ExcelGeneral)? Feature Requests submitted to Tech Community are regularly reviewed by the product teams as they plan future releases. Thanks! 54 | - closeIssue 55 | - description: 56 | frequencies: 57 | - hourly: 58 | hour: 3 59 | filters: 60 | - isIssue 61 | - isOpen 62 | - hasLabel: 63 | label: 'Needs: author feedback' 64 | - hasLabel: 65 | label: 'Status: no recent activity' 66 | - noActivitySince: 67 | days: 3 68 | actions: 69 | - addReply: 70 | reply: This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue. 71 | - closeIssue 72 | eventResponderTasks: 73 | - if: 74 | - payloadType: Issues 75 | - isAction: 76 | action: Opened 77 | - not: isAssignedToSomeone 78 | then: 79 | - addLabel: 80 | label: 'Needs: triage :mag:' 81 | description: 82 | - if: 83 | - payloadType: Issues 84 | - not: 85 | isAction: 86 | action: Closed 87 | - hasLabel: 88 | label: 'Status: no recent activity' 89 | then: 90 | - removeLabel: 91 | label: 'Status: no recent activity' 92 | description: 93 | - if: 94 | - payloadType: Issue_Comment 95 | - hasLabel: 96 | label: 'Status: no recent activity' 97 | then: 98 | - removeLabel: 99 | label: 'Status: no recent activity' 100 | description: 101 | - if: 102 | - payloadType: Issue_Comment 103 | - isAction: 104 | action: Created 105 | - isActivitySender: 106 | issueAuthor: True 107 | - hasLabel: 108 | label: 'Needs: author feedback' 109 | then: 110 | - addLabel: 111 | label: 'Needs: attention :wave:' 112 | - removeLabel: 113 | label: 'Needs: author feedback' 114 | description: 115 | - if: 116 | - payloadType: Pull_Request 117 | then: 118 | - inPrLabel: 119 | label: 'Status: in PR' 120 | description: 121 | - if: 122 | - payloadType: Issues 123 | - labelAdded: 124 | label: 'Status: in PR' 125 | - hasLabel: 126 | label: 'Status: under investigation' 127 | then: 128 | - removeLabel: 129 | label: 'Status: under investigation' 130 | description: 131 | triggerOnOwnActions: true 132 | - if: 133 | - payloadType: Issues 134 | - labelAdded: 135 | label: 'Status: in PR' 136 | - hasLabel: 137 | label: 'Status: in backlog' 138 | then: 139 | - removeLabel: 140 | label: 'Status: in backlog' 141 | description: 142 | triggerOnOwnActions: true 143 | - if: 144 | - payloadType: Issues 145 | - labelAdded: 146 | label: 'Status: in PR' 147 | - hasLabel: 148 | label: 'Needs: attention :wave:' 149 | then: 150 | - removeLabel: 151 | label: 'Needs: attention :wave:' 152 | description: 153 | triggerOnOwnActions: true 154 | onFailure: 155 | onSuccess: 156 | -------------------------------------------------------------------------------- /.github/workflows/auto-publish.yml: -------------------------------------------------------------------------------- 1 | name: auto-publish 2 | run-name: Automatically publish documentation 3 | on: 4 | schedule: 5 | # Run at 2:15 AM UTC on Wednesday and Friday 6 | - cron: '15 2 * * WED,FRI' 7 | jobs: 8 | auto-publish: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | contents: write 12 | defaults: 13 | run: 14 | shell: bash 15 | working-directory: ./ 16 | steps: 17 | - name: Check out repository 18 | uses: actions/checkout@v4 19 | with: 20 | fetch-depth: 0 21 | - name: Check out main 22 | run: | 23 | echo "Checking out main branch" 24 | git config user.name github-actions 25 | git config user.email github-actions@github.com 26 | git checkout main 27 | - name: Check out live 28 | run: | 29 | echo "Checking out live branch" 30 | git checkout live 31 | - name: Merge from main into live 32 | run: | 33 | echo "Merging from main to live" 34 | git merge main 35 | - name: Push changes 36 | run: | 37 | echo "Pushing changes to live branch" 38 | git push origin live 39 | 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | log/ 2 | obj/ 3 | _site/ 4 | .optemp/ 5 | _themes*/ 6 | _repo.*/ 7 | .vscode/ 8 | 9 | .openpublishing.buildcore.ps1 -------------------------------------------------------------------------------- /.openpublishing.publish.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "docsets_to_publish": [ 3 | { 4 | "docset_name": "office-scripts-docs", 5 | "build_source_folder": "docs", 6 | "build_output_subfolder": "office-scripts-docs", 7 | "locale": "en-us", 8 | "monikers": [], 9 | "moniker_ranges": [ 10 | "office-scripts" 11 | ], 12 | "open_to_public_contributors": true, 13 | "type_mapping": { 14 | "Conceptual": "Content", 15 | "Tutorial": "Content", 16 | "LandingPage": "Content" 17 | }, 18 | "build_entry_point": "docs", 19 | "template_folder": "_themes", 20 | "customized_tasks": { 21 | "docset_prebuild": [ 22 | "_dependentPackages/CommonPlugins/tools/JoinTOC.ps1" 23 | ] 24 | } 25 | } 26 | ], 27 | "notification_subscribers": [ 28 | "aljerabe@microsoft.com" 29 | ], 30 | "sync_notification_subscribers": [], 31 | "branches_to_filter": [], 32 | "git_repository_url_open_to_public_contributors": "https://github.com/OfficeDev/office-scripts-docs", 33 | "git_repository_branch_open_to_public_contributors": "main", 34 | "skip_source_output_uploading": false, 35 | "need_preview_pull_request": true, 36 | "contribution_branch_mappings": {}, 37 | "dependent_repositories": [ 38 | { 39 | "path_to_root": "_themes", 40 | "url": "https://github.com/Microsoft/templates.docs.msft", 41 | "branch": "main", 42 | "branch_mapping": {} 43 | }, 44 | { 45 | "path_to_root": "_themes.pdf", 46 | "url": "https://github.com/Microsoft/templates.docs.msft.pdf", 47 | "branch": "main", 48 | "branch_mapping": {} 49 | } 50 | ], 51 | "branch_target_mapping": { 52 | "live": [ 53 | "Publish", 54 | "Pdf" 55 | ] 56 | }, 57 | "need_generate_pdf_url_template": true, 58 | "targets": { 59 | "pdf": { 60 | "template_folder": "_themes.pdf" 61 | } 62 | }, 63 | "docs_build_engine": { 64 | "name": "docfx_v3" 65 | }, 66 | "JoinTOCPlugin": [ 67 | { 68 | "ConceptualTOC": "docs/toc.yml", 69 | "ReferenceTOCUrl": "/javascript/api/office-scripts/toc.json" 70 | } 71 | ], 72 | "dependent_packages": [ 73 | { 74 | "id": "Microsoft.OpenPublishing.CommonPlugins", 75 | "nuget_feed": "https://www.myget.org/F/op/api/v2", 76 | "path_to_root": "_dependentPackages/CommonPlugins", 77 | "target_framework": "net45", 78 | "version": "latest" 79 | } 80 | ] 81 | } -------------------------------------------------------------------------------- /.openpublishing.redirection.json: -------------------------------------------------------------------------------- 1 | { 2 | "redirections": [ 3 | { 4 | "source_path": "docs/develop/vscode-for-scripts.md", 5 | "redirect_url": "/office/dev/scripts" 6 | }, 7 | { 8 | "source_path": "docs/resources/excel-samples.md", 9 | "redirect_url": "/office/dev/scripts/resources/samples/samples-overview" 10 | }, 11 | { 12 | "source_path": "docs/resources/samples/excel-samples.md", 13 | "redirect_url": "/office/dev/scripts/resources/samples/samples-overview" 14 | }, 15 | { 16 | "source_path": "docs/resources/samples/clear-table-filter-for-active-cell.md", 17 | "redirect_url": "/office/dev/scripts/resources/samples/table-samples" 18 | }, 19 | { 20 | "source_path": "docs/resources/samples/document-number-generator.md", 21 | "redirect_url": "/office/dev/scripts/resources/samples/samples-overview" 22 | }, 23 | { 24 | "source_path": "docs/resources/samples/filter-table-get-visible-range.md", 25 | "redirect_url": "/office/dev/scripts/resources/samples/table-samples" 26 | }, 27 | { 28 | "source_path": "docs/resources/samples/range-basics.md", 29 | "redirect_url": "/office/dev/scripts/resources/samples/excel-samples" 30 | }, 31 | { 32 | "source_path": "docs/resources/scenarios/sample-scenario-overview.md", 33 | "redirect_url": "/office/dev/scripts/resources/samples/samples-overview", 34 | "redirect_document_id": true 35 | }, 36 | { 37 | "source_path": "docs/tutorials/excel-office-scripts-tutorial.md", 38 | "redirect_url": "/office/dev/scripts/tutorials/excel-tutorial" 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /LICENSE-CODE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) Microsoft Corporation 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial 11 | portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 15 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 16 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 17 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Office Scripts documentation 2 | 3 | Welcome to the Office Scripts documentation repository. In this repo, you can find the documentation source files for Office Scripts tutorials and how-to guides. For the best experience, we recommend you view this content on [Microsoft Learn](https://learn.microsoft.com/office/dev/scripts). 4 | 5 | > **NOTE**: You can find the reference documentation source files for the Office Scripts API in the [office-scripts-docs-reference](https://github.com/OfficeDev/office-scripts-docs-reference) repository. These APIs contain all the potential operations for your scripts. 6 | 7 | ## Give us your feedback 8 | 9 | The goal of the repo is to provide developer education about Office Scripts. As such, issues should pertain to that educational content. Please [submit an issue](https://github.com/OfficeDev/office-scripts-docs/issues) for the following scenarios: 10 | 11 | - Information needed to succeed in developing Office Scripts is missing or incomplete. 12 | - Information is inaccurate or obsolete. 13 | - You find typos, grammatical mistakes, or other problems with the articles. 14 | - Articles are organized in a confusing or unintuitive manner. 15 | 16 | If you are seeing product behavior that differs from the documentation, please provide as much of the following information as is possible and relevant: 17 | 18 | - The version and build number of the client you are using. 19 | - Steps to reproduce the issue. 20 | - Console output and error messages. 21 | 22 | We also encourage you to fork, make the fix, and do a pull request of your proposed changes. For details, see [Contribute to this documentation](Contributing.md). 23 | 24 | If your issue is not related to the Office Scripts documentation, please post it to one of the following channels instead: 25 | 26 | - To ask a question about designing Office Scripts or the Office.js API that runs Office Scripts, post your question to Stack Overflow and tag it with the ["office-scripts" tag](https://stackoverflow.com/questions/tagged/office-scripts). 27 | - To report an issue with the Office.js API, create the issue in the [OfficeDev/office-js repository](https://github.com/OfficeDev/office-js), which members of the product team monitor for customer-reported issues. 28 | 29 | ## Copyright 30 | 31 | Copyright (c) 2019 Microsoft Corporation. All rights reserved. 32 | 33 | ## Microsoft Open Source Code of Conduct 34 | 35 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 36 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 37 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how a threat actor might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /ThirdPartyNotices.md: -------------------------------------------------------------------------------- 1 | ## Legal Notices 2 | Microsoft and any contributors grant you a license to the Microsoft documentation and other content 3 | in this repository under the [Creative Commons Attribution 4.0 International Public License](https://creativecommons.org/licenses/by/4.0/legalcode), 4 | see the [LICENSE](LICENSE) file, and grant you a license to any code in the repository under the [MIT License](https://opensource.org/licenses/MIT), see the 5 | [LICENSE-CODE](LICENSE-CODE) file. 6 | 7 | Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation 8 | may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. 9 | The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. 10 | Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653. 11 | 12 | Privacy information can be found at https://privacy.microsoft.com/en-us/ 13 | 14 | Microsoft and any contributors reserve all others rights, whether under their respective copyrights, patents, 15 | or trademarks, whether by implication, estoppel or otherwise. -------------------------------------------------------------------------------- /docs/breadcrumb/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Microsoft 365 2 | tocHref: /office/dev/scripts/ 3 | topicHref: /microsoft-365/index 4 | -------------------------------------------------------------------------------- /docs/develop/external-calls.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: External API call support in Office Scripts 3 | description: Support and guidance for making external API calls in an Office Script. 4 | ms.date: 04/27/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # External API call support in Office Scripts 9 | 10 | Scripts support calls to external services. Use these services to supply data and other information to your workbook. 11 | 12 | > [!CAUTION] 13 | > External calls may result in sensitive data being exposed to undesirable endpoints. Your admin can establish Information Rights Management (IRM) or firewall protection against such calls. 14 | 15 | > [!IMPORTANT] 16 | > Calls to external APIs can only be made through the Excel application, not through Power Automate [under normal circumstances](#external-calls-from-power-automate). External calls are also not supported for scripts stored on a SharePoint site. 17 | 18 | ## Configure your script for external calls 19 | 20 | External calls are [asynchronous](https://developer.mozilla.org/docs/Learn/JavaScript/Asynchronous/Async_await) and require that your script is marked as `async`. Add the `async` prefix to your `main` function and have it return a `Promise`, as shown here: 21 | 22 | ```typescript 23 | async function main(workbook: ExcelScript.Workbook) : Promise 24 | ``` 25 | 26 | > [!NOTE] 27 | > Scripts that return other information can return a `Promise` of that type. For example, if your script needs to return an `Employee` object, the return signature would be `: Promise ` 28 | 29 | You'll need to learn the external service's interfaces to make calls to that service. If you are using `fetch` or [REST APIs](https://wikipedia.org/wiki/Representational_state_transfer), you need to determine the JSON structure of the returned data. For both input to and output from your script, consider making an `interface` to match the needed JSON structures. This gives the script more type safety. You can see an example of this in [Using fetch from Office Scripts](../resources/samples/external-fetch-calls.md). 30 | 31 | ### Limitations with external calls from Office Scripts 32 | 33 | * There is no way to sign in or use OAuth2 type of authentication flows. All keys and credentials have to be hardcoded (or read from another source). 34 | * There is no infrastructure to store API credentials and keys. This will have to be managed by the user. 35 | * Document cookies, `localStorage`, and `sessionStorage` objects are not supported. 36 | * External calls may result in sensitive data being exposed to undesirable endpoints, or external data to be brought into internal workbooks. Your admin can establish firewall protection against such calls. Be sure to check with local policies prior to relying on external calls. 37 | * Be sure to check the amount of data throughput prior to taking a dependency. For instance, pulling down the entire external dataset may not be the best option and instead pagination should be used to get data in chunks. 38 | 39 | ## Retrieve information with `fetch` 40 | 41 | The [fetch API](https://developer.mozilla.org/docs/Web/API/Fetch_API) retrieves information from external services. It is an `async` API, so you need to adjust the `main` signature of your script. Make the `main` function `async`. You should also be sure to `await` the `fetch` call and `json` retrieval. This ensures those operations complete before the script ends. 42 | 43 | Any JSON data retrieved by `fetch` must match an interface defined in the script. The returned value must be assigned to a specific type because [Office Scripts do not support the `any` type](typescript-restrictions.md#no-any-type-in-office-scripts). You should refer to the documentation for your service to see what the names and types of the returned properties are. Then, add the matching interface or interfaces to your script. 44 | 45 | The following script uses `fetch` to retrieve JSON data from the test server in the given URL. Note the `JSONData` interface to store the data as a matching type. 46 | 47 | ```TypeScript 48 | async function main(workbook: ExcelScript.Workbook) { 49 | // Retrieve sample JSON data from a test server. 50 | let fetchResult = await fetch('https://jsonplaceholder.typicode.com/todos/1'); 51 | 52 | // Convert the returned data to the expected JSON structure. 53 | let json : JSONData = await fetchResult.json(); 54 | 55 | // Display the content in a readable format. 56 | console.log(JSON.stringify(json)); 57 | } 58 | 59 | /** 60 | * An interface that matches the returned JSON structure. 61 | * The property names match exactly. 62 | */ 63 | interface JSONData { 64 | userId: number; 65 | id: number; 66 | title: string; 67 | completed: boolean; 68 | } 69 | ``` 70 | 71 | ### Other `fetch` samples 72 | 73 | * The [Use external fetch calls in Office Scripts](../resources/samples/external-fetch-calls.md) sample shows how to get basic information about a user's GitHub repositories. 74 | * Samples in the [Use JSON to pass data to and from Office Scripts](use-json.md) article show how to pass data to and from `fetch` commands as JSON. 75 | * The [Office Scripts sample scenario: Graph water-level data from NOAA](../resources/scenarios/noaa-data-fetch.md) demonstrates the `fetch` command being used to retrieve records from the National Oceanic and Atmospheric Administration's Tides and Currents database. 76 | * The second sample in [Add images to a workbook](../resources/samples/add-image-to-workbook.md) contains a `fetch` call to get an image from a website. 77 | 78 | ## Restrict external calls with Information Rights Management (IRM) 79 | 80 | You can [apply IRM settings](/microsoft-365/compliance/apply-irm-to-a-list-or-library) to a workbook to prevent external calls being made by scripts. Disable the [**Copy**/**EXTRACT** policy](/azure/information-protection/configure-usage-rights#usage-rights-and-descriptions) to prevent this behavior. 81 | 82 | ## External calls from Power Automate 83 | 84 | [!INCLUDE [External calls in Power Automate](../includes/external-calls-power-automate.md)] 85 | 86 | ## See also 87 | 88 | * [Use JSON to pass data to and from Office Scripts](use-json.md) 89 | * [Using built-in JavaScript objects in Office Scripts](javascript-objects.md) 90 | * [Use external fetch calls in Office Scripts](../resources/samples/external-fetch-calls.md) 91 | * [Office Scripts sample scenario: Graph water-level data from NOAA](../resources/scenarios/noaa-data-fetch.md) 92 | -------------------------------------------------------------------------------- /docs/develop/macros-power-automate.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Use macro-enabled files in Power Automate flows 3 | description: Learn how to use macro-enabled files, or .xlsm files, in Power Automate flows. 4 | ms.date: 05/08/2024 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # How to use macro-enabled files in Power Automate flows 9 | 10 | [Power Automate](https://make.powerautomate.com/) flows support .xlsm files in the [Excel Online (Business) connector](https://make.powerautomate.com/connectors/shared_excelonlinebusiness/excel-online-business/). However, only the **Run script** action lets you select .xlsm files through the file browser. Other connector actions require you use the file ID. 11 | 12 | Get the file ID with a **Get File Metadata** action from either the [OneDrive for Business](https://make.powerautomate.com/connectors/shared_onedriveforbusiness/onedrive-for-business/) or [SharePoint](https://make.powerautomate.com/connectors/shared_sharepointonline/sharepoint/) connectors. Use the *ID* dynamic content returned from the **Get file metadata** action as the "File" argument for Excel connector actions. Note that parameters such as "Table" in the **Add a row into a table** action won't automatically propagate a dropdown list of tables to choose. You'll need to enter the name of the table or other Excel object. 13 | 14 | > [!IMPORTANT] 15 | > The macros contained in the .xlsm files cannot be run through Power Automate. Only Office Scripts are enabled there. 16 | 17 | > [!WARNING] 18 | > Some .xlsm files, especially those with ActiveX or Form controls, may not work in the Excel online connector. Be sure to test before deploying your solution. 19 | 20 | ## See also 21 | 22 | - [Excel Online (Business) connector reference](/connectors/excelonlinebusiness/) 23 | - [Run Office Scripts with Power Automate](power-automate-integration.md) 24 | -------------------------------------------------------------------------------- /docs/develop/pivottable-sample.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/develop/pivottable-sample.xlsx -------------------------------------------------------------------------------- /docs/develop/power-automate-parameters-returns.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pass data to and from scripts in Power Automate 3 | description: How and why to use parameters and return values in Office Scripts with Power Automate. 4 | ms.date: 11/29/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Pass data to and from scripts in Power Automate 9 | 10 | Power Automate chains together separate programs into a single automated workflow. Each connector has different parameters it accepts and different values it returns. Your scripts can be written to expand the "Run script" Power Automate action to get additional input or give output. 11 | 12 | Input for your script is specified by adding parameters to the `main` function. Output from the script is declared by adding a return type to `main`. 13 | 14 | > [!NOTE] 15 | > When you create a "Run script" block in your flow, the accepted parameters and returned types are populated. If you change the parameters or return types of your script, you'll need to redo the "Run script" block of your flow. This ensures the data is being parsed correctly. 16 | 17 | ## Pass data to scripts with parameters 18 | 19 | Add parameters to scripts to provide input from other parts of the flow. It's the same process to add parameters for flow-based scripts as it is for scripts run through the Excel client. Learn about providing input to scripts in [Get user input for scripts](user-input.md). 20 | 21 | The following screenshot shows what a script with the signature `function main(workbook: ExcelScript.Workbook, location: string = "Seattle")` would display. 22 | 23 | :::image type="content" source="../images/power-automate-default-parameter.png" alt-text="The Run script action showing an additional parameter field called 'Location' with a pre-populated value of 'Seattle'."::: 24 | 25 | The [dropdown menus created by type unions](user-input.md#dropdown-lists-for-parameters) also function the same in Power Automate. 26 | 27 | :::image type="content" source="../images/power-automate-drop-down-parameter-choices.png" alt-text="The Run script action showing an additional parameter field called 'Location' with choices between 'Seattle' and 'Redmond'."::: 28 | 29 | ## Return data from a script 30 | 31 | Scripts can return data from the workbook to be used as dynamic content in a Power Automate flow. To return an object, add the return type syntax to the `main` function. For example, if you wanted to return a `string` value from the script, your `main` signature would be `function main(workbook: ExcelScript.Workbook): string`. 32 | 33 | Returned values are shown as dynamic content from the Run script action in the flow. The dynamic content is named "result". 34 | 35 | :::image type="content" source="../images/power-automate-return-dynamic-content.png" alt-text="The dynamic content selector in Power Automate showing an entry from a Run script action named 'result'."::: 36 | 37 | Acceptable types for returning data are the same as for parameters. Details on type restrictions are found in the article [Get user input for scripts](user-input.md#type-restrictions). 38 | 39 | ## See also 40 | 41 | - [Tutorial: Update a spreadsheet from a Power Automate flow](../tutorials/excel-power-automate-manual.md) 42 | - [Get user input for scripts](user-input.md) 43 | - [Run Office Scripts with Power Automate](power-automate-integration.md) 44 | - [Troubleshooting information for Power Automate with Office Scripts](../testing/power-automate-troubleshooting.md) 45 | -------------------------------------------------------------------------------- /docs/develop/script-buttons.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Run Office Scripts in Excel from buttons 3 | description: Add buttons to workbooks that control Office Scripts in Excel. 4 | ms.topic: overview 5 | ms.date: 06/06/2024 6 | ms.localizationpriority: medium 7 | --- 8 | 9 | # Run Office Scripts in Excel from buttons 10 | 11 | Help your colleagues find and run your scripts by adding script buttons to a workbook. 12 | 13 | :::image type="content" source="../images/run-from-button.png" alt-text="A button in the worksheet that runs a script when clicked."::: 14 | 15 | > [!NOTE] 16 | > Script buttons aren't available during the Office Scripts preview for personal and family Microsoft 365 subscriptions. 17 | 18 | ## Create script buttons 19 | 20 | When viewing a script, select **Add in workbook**. This creates a button in the workbook that runs the associated script. It also shares the script with the workbook, so everyone with write permissions to the workbook can use your helpful automation. 21 | 22 | :::image type="content" source="../images/add-button.png" alt-text="The 'Add in workbook' button on the 'Create Report' script details page with a button named 'Create Report' shown in the Excel grid."::: 23 | 24 | > [!IMPORTANT] 25 | > If OneDrive sharing is restricted by organizational policies, you can't create a script button. 26 | 27 | ## Remove script buttons 28 | 29 | To stop sharing a script through a button, select the arrow next to **Add in workbook** and choose the option **Remove from workbook**. This removes all the buttons that run the script. Deleting a single button removes the script from that one button, even if the operation is undone or the button is cut and pasted. 30 | 31 | :::image type="content" source="../images/remove-button.png" alt-text="The 'Remove from workbook' option on the script details page."::: 32 | 33 | ## Older versions of Excel 34 | 35 | Script buttons won't work when opened in [versions of Excel that don't support Office Scripts](../testing/platform-limits.md#platform-support). In that case, the button still appears, but selecting it has no effect. 36 | 37 | ## See also 38 | 39 | - [Platform limits and requirements with Office Scripts](../testing/platform-limits.md) 40 | -------------------------------------------------------------------------------- /docs/docfx.json: -------------------------------------------------------------------------------- 1 | 2 | 3 | { 4 | "build": { 5 | "content": [ 6 | { 7 | "files": [ 8 | "**/*.md", 9 | "**/*.yml" 10 | ], 11 | "exclude": [ 12 | "**/obj/**", 13 | "**/includes/**", 14 | "README.md", 15 | "LICENSE", 16 | "LICENSE-CODE", 17 | "ThirdPartyNotices.md" 18 | ] 19 | } 20 | ], 21 | "resource": [ 22 | { 23 | "files": [ 24 | "**/*.png", 25 | "**/*.jpg", 26 | "**/*.gif", 27 | "**/*.svg", 28 | "**/*.xlsx" 29 | ], 30 | "exclude": [ 31 | "**/obj/**", 32 | "**/includes/**" 33 | ] 34 | } 35 | ], 36 | "overwrite": [], 37 | "externalReference": [], 38 | "globalMetadata": { 39 | "uhfHeaderId": "office-scripts", 40 | "searchScope": ["Office Scripts"], 41 | "breadcrumb_path": "/office/dev/scripts/breadcrumb/toc.json", 42 | "ms.suite": "office", 43 | "ms.author": "o365devx", 44 | "author": "o365devx", 45 | "ms.topic": "conceptual", 46 | "ms.subservice": "scripts", 47 | "ms.service": "excel", 48 | "feedback_system": "OpenSource", 49 | "feedback_product_url": "/answers/tags/321/office-development", 50 | "open_source_feedback_contributorGuideUrl": "https://github.com/OfficeDev/office-scripts-docs/blob/main/Contributing.md", 51 | "open_source_feedback_issueTitle": "", 52 | "open_source_feedback_issueUrl": "https://github.com/OfficeDev/office-scripts-docs/issues/new?template=3_customer-feedback.yml", 53 | "open_source_feedback_productName": "Office Scripts", 54 | "titleSuffix": "Office Scripts" 55 | }, 56 | "fileMetadata": { 57 | "ms.topic": { 58 | "resources/samples/*.md": "sample", 59 | "resources/scenarios/*.md": "sample", 60 | "tutorials/*.md": "tutorial" 61 | }, 62 | "ms.custom": { 63 | "tutorials/*.md": "scenarios:getting-started; languages:JavaScript,TypeScript" 64 | } 65 | }, 66 | "template": [], 67 | "dest": "office-scripts-docs", 68 | "markdownEngineName": "markdig" 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /docs/images/action-recorder-copy-code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/action-recorder-copy-code.png -------------------------------------------------------------------------------- /docs/images/action-recorder-intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/action-recorder-intro.png -------------------------------------------------------------------------------- /docs/images/add-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/add-button.png -------------------------------------------------------------------------------- /docs/images/after-filter-cleared.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/after-filter-cleared.png -------------------------------------------------------------------------------- /docs/images/all-files-in-folder-sample-flow-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/all-files-in-folder-sample-flow-1.PNG -------------------------------------------------------------------------------- /docs/images/all-files-in-folder-sample-flow-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/all-files-in-folder-sample-flow-2.PNG -------------------------------------------------------------------------------- /docs/images/all-files-in-folder-sample-flow-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/all-files-in-folder-sample-flow-3.PNG -------------------------------------------------------------------------------- /docs/images/all-files-in-folder-sample-flow-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/all-files-in-folder-sample-flow-4.png -------------------------------------------------------------------------------- /docs/images/audit-log-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/audit-log-example.png -------------------------------------------------------------------------------- /docs/images/automate-a-task-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/automate-a-task-button.png -------------------------------------------------------------------------------- /docs/images/automate-a-task-choices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/automate-a-task-choices.png -------------------------------------------------------------------------------- /docs/images/before-filter-applied.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/before-filter-applied.png -------------------------------------------------------------------------------- /docs/images/blank-rows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/blank-rows.png -------------------------------------------------------------------------------- /docs/images/chart-created.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/chart-created.png -------------------------------------------------------------------------------- /docs/images/chart-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/chart-sample.png -------------------------------------------------------------------------------- /docs/images/code-editor-feedback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/code-editor-feedback.png -------------------------------------------------------------------------------- /docs/images/code-editor-intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/code-editor-intro.png -------------------------------------------------------------------------------- /docs/images/combine-worksheets-flow-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/combine-worksheets-flow-1.PNG -------------------------------------------------------------------------------- /docs/images/combine-worksheets-flow-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/combine-worksheets-flow-2.PNG -------------------------------------------------------------------------------- /docs/images/combine-worksheets-flow-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/combine-worksheets-flow-3.PNG -------------------------------------------------------------------------------- /docs/images/combine-worksheets-flow-4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/combine-worksheets-flow-4.PNG -------------------------------------------------------------------------------- /docs/images/combine-worksheets-flow-5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/combine-worksheets-flow-5.PNG -------------------------------------------------------------------------------- /docs/images/combine-worksheets-flow-workbook-name-shorten-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/combine-worksheets-flow-workbook-name-shorten-flow.png -------------------------------------------------------------------------------- /docs/images/combine-worksheets-flow-workbook-name-shorten.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/combine-worksheets-flow-workbook-name-shorten.png -------------------------------------------------------------------------------- /docs/images/conditional-formatting-sample-cell-value.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/conditional-formatting-sample-cell-value.png -------------------------------------------------------------------------------- /docs/images/conditional-formatting-sample-color-scale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/conditional-formatting-sample-color-scale.png -------------------------------------------------------------------------------- /docs/images/conditional-formatting-sample-custom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/conditional-formatting-sample-custom.png -------------------------------------------------------------------------------- /docs/images/conditional-formatting-sample-data-bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/conditional-formatting-sample-data-bar.png -------------------------------------------------------------------------------- /docs/images/conditional-formatting-sample-icon-set.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/conditional-formatting-sample-icon-set.png -------------------------------------------------------------------------------- /docs/images/conditional-formatting-sample-preset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/conditional-formatting-sample-preset.png -------------------------------------------------------------------------------- /docs/images/conditional-formatting-sample-text-comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/conditional-formatting-sample-text-comparison.png -------------------------------------------------------------------------------- /docs/images/conditional-formatting-sample-top-bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/conditional-formatting-sample-top-bottom.png -------------------------------------------------------------------------------- /docs/images/convert-csv-flow-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/convert-csv-flow-1.png -------------------------------------------------------------------------------- /docs/images/convert-csv-flow-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/convert-csv-flow-2.png -------------------------------------------------------------------------------- /docs/images/convert-csv-flow-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/convert-csv-flow-3.png -------------------------------------------------------------------------------- /docs/images/convert-csv-flow-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/convert-csv-flow-4.png -------------------------------------------------------------------------------- /docs/images/convert-csv-flow-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/convert-csv-flow-5.png -------------------------------------------------------------------------------- /docs/images/convert-csv-flow-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/convert-csv-flow-6.png -------------------------------------------------------------------------------- /docs/images/convert-csv-flow-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/convert-csv-flow-7.png -------------------------------------------------------------------------------- /docs/images/create-json-console-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/create-json-console-output.png -------------------------------------------------------------------------------- /docs/images/cross-reference-flow-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/cross-reference-flow-1.PNG -------------------------------------------------------------------------------- /docs/images/cross-reference-flow-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/cross-reference-flow-2.PNG -------------------------------------------------------------------------------- /docs/images/cross-reference-flow-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/cross-reference-flow-3.PNG -------------------------------------------------------------------------------- /docs/images/cross-reference-flow-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/cross-reference-flow-4.png -------------------------------------------------------------------------------- /docs/images/data-validation-error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/data-validation-error.png -------------------------------------------------------------------------------- /docs/images/data-validation-prompt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/data-validation-prompt.png -------------------------------------------------------------------------------- /docs/images/day-to-day-changes-flow-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/day-to-day-changes-flow-1.png -------------------------------------------------------------------------------- /docs/images/day-to-day-changes-flow-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/day-to-day-changes-flow-2.png -------------------------------------------------------------------------------- /docs/images/day-to-day-changes-flow-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/day-to-day-changes-flow-3.png -------------------------------------------------------------------------------- /docs/images/day-to-day-changes-flow-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/day-to-day-changes-flow-4.png -------------------------------------------------------------------------------- /docs/images/email-chart-sample-flow-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/email-chart-sample-flow-1.PNG -------------------------------------------------------------------------------- /docs/images/email-chart-sample-flow-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/email-chart-sample-flow-2.PNG -------------------------------------------------------------------------------- /docs/images/email-received.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/email-received.png -------------------------------------------------------------------------------- /docs/images/explicit-any-editor-message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/explicit-any-editor-message.png -------------------------------------------------------------------------------- /docs/images/explicit-any-error-message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/explicit-any-error-message.png -------------------------------------------------------------------------------- /docs/images/git-octocat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/git-octocat.png -------------------------------------------------------------------------------- /docs/images/git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/git.png -------------------------------------------------------------------------------- /docs/images/implicit-any-editor-message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/implicit-any-editor-message.png -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_architecture.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_article.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | 24 | i_article 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_bug.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | i_bug 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_code-blocks.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20 | 21 | i_code-blocks 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_code-samples.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | i_code-samples 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_feedback.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 26 | 27 | i_feedback 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_get-started.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38 | 39 | i_get-started 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_library.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | 20 | i_library 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_reference.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | 20 | i_reference 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_share.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_support.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 27 | 28 | i_support 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/images/index-landing-page/i_upgrade.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/images/input-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/input-data.png -------------------------------------------------------------------------------- /docs/images/json-parameter-power-automate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/json-parameter-power-automate.png -------------------------------------------------------------------------------- /docs/images/load-sync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/load-sync.png -------------------------------------------------------------------------------- /docs/images/load-sync.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/load-sync.vsdx -------------------------------------------------------------------------------- /docs/images/no-blank-rows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/no-blank-rows.png -------------------------------------------------------------------------------- /docs/images/office-programmability-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/office-programmability-diagram.png -------------------------------------------------------------------------------- /docs/images/office-programmability-diagram.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/office-programmability-diagram.pptx -------------------------------------------------------------------------------- /docs/images/outlook-connector-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/outlook-connector-settings.png -------------------------------------------------------------------------------- /docs/images/pivottable-data-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/pivottable-data-hierarchy.png -------------------------------------------------------------------------------- /docs/images/pivottable-empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/pivottable-empty.png -------------------------------------------------------------------------------- /docs/images/pivottable-filter-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/pivottable-filter-hierarchy.png -------------------------------------------------------------------------------- /docs/images/pivottable-filters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/pivottable-filters.png -------------------------------------------------------------------------------- /docs/images/pivottable-layout-breakdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/pivottable-layout-breakdown.png -------------------------------------------------------------------------------- /docs/images/pivottable-object-model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/pivottable-object-model.png -------------------------------------------------------------------------------- /docs/images/pivottable-object-model.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/pivottable-object-model.vsdx -------------------------------------------------------------------------------- /docs/images/pivottable-raw-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/pivottable-raw-data.png -------------------------------------------------------------------------------- /docs/images/power-automate-default-parameter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-default-parameter.png -------------------------------------------------------------------------------- /docs/images/power-automate-drop-down-parameter-choices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-drop-down-parameter-choices.png -------------------------------------------------------------------------------- /docs/images/power-automate-file-browser.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-file-browser.PNG -------------------------------------------------------------------------------- /docs/images/power-automate-parameter-return-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-parameter-return-sample.png -------------------------------------------------------------------------------- /docs/images/power-automate-params-tutorial-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-params-tutorial-1.png -------------------------------------------------------------------------------- /docs/images/power-automate-params-tutorial-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-params-tutorial-2.png -------------------------------------------------------------------------------- /docs/images/power-automate-params-tutorial-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-params-tutorial-3.png -------------------------------------------------------------------------------- /docs/images/power-automate-params-tutorial-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-params-tutorial-4.png -------------------------------------------------------------------------------- /docs/images/power-automate-params-tutorial-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-params-tutorial-5.png -------------------------------------------------------------------------------- /docs/images/power-automate-return-dynamic-content.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-return-dynamic-content.png -------------------------------------------------------------------------------- /docs/images/power-automate-return-tutorial-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-return-tutorial-1.PNG -------------------------------------------------------------------------------- /docs/images/power-automate-return-tutorial-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-return-tutorial-2.PNG -------------------------------------------------------------------------------- /docs/images/power-automate-return-tutorial-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-return-tutorial-3.PNG -------------------------------------------------------------------------------- /docs/images/power-automate-return-tutorial-4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-return-tutorial-4.PNG -------------------------------------------------------------------------------- /docs/images/power-automate-return-tutorial-5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-return-tutorial-5.PNG -------------------------------------------------------------------------------- /docs/images/power-automate-return-tutorial-6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-return-tutorial-6.PNG -------------------------------------------------------------------------------- /docs/images/power-automate-return-tutorial-7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-return-tutorial-7.PNG -------------------------------------------------------------------------------- /docs/images/power-automate-tutorial-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-tutorial-1.png -------------------------------------------------------------------------------- /docs/images/power-automate-tutorial-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-tutorial-10.png -------------------------------------------------------------------------------- /docs/images/power-automate-tutorial-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-tutorial-2.png -------------------------------------------------------------------------------- /docs/images/power-automate-tutorial-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-tutorial-3.png -------------------------------------------------------------------------------- /docs/images/power-automate-tutorial-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-tutorial-4.png -------------------------------------------------------------------------------- /docs/images/power-automate-tutorial-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-tutorial-5.png -------------------------------------------------------------------------------- /docs/images/power-automate-tutorial-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-tutorial-6.png -------------------------------------------------------------------------------- /docs/images/power-automate-tutorial-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-tutorial-7.png -------------------------------------------------------------------------------- /docs/images/power-automate-tutorial-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-tutorial-8.png -------------------------------------------------------------------------------- /docs/images/power-automate-tutorial-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-automate-tutorial-9.png -------------------------------------------------------------------------------- /docs/images/power-query-flow-option.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/power-query-flow-option.PNG -------------------------------------------------------------------------------- /docs/images/punch-clock-sample-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/punch-clock-sample-1.png -------------------------------------------------------------------------------- /docs/images/punch-clock-sample-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/punch-clock-sample-2.png -------------------------------------------------------------------------------- /docs/images/range-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/range-sample.png -------------------------------------------------------------------------------- /docs/images/reference-documentation-version-picker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/reference-documentation-version-picker.png -------------------------------------------------------------------------------- /docs/images/remove-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/remove-button.png -------------------------------------------------------------------------------- /docs/images/run-from-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/run-from-button.png -------------------------------------------------------------------------------- /docs/images/run-script-from-sp-library.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/run-script-from-sp-library.png -------------------------------------------------------------------------------- /docs/images/run-script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/run-script.png -------------------------------------------------------------------------------- /docs/images/runtime-error-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/runtime-error-console.png -------------------------------------------------------------------------------- /docs/images/sample-data-validation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/sample-data-validation.png -------------------------------------------------------------------------------- /docs/images/sample-pivottable-grand-total-row.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/sample-pivottable-grand-total-row.png -------------------------------------------------------------------------------- /docs/images/scenario-analyze-web-downloads-after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-analyze-web-downloads-after.png -------------------------------------------------------------------------------- /docs/images/scenario-analyze-web-downloads-before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-analyze-web-downloads-before.png -------------------------------------------------------------------------------- /docs/images/scenario-analyze-web-downloads-table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-analyze-web-downloads-table.png -------------------------------------------------------------------------------- /docs/images/scenario-grade-calculator-after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-grade-calculator-after.png -------------------------------------------------------------------------------- /docs/images/scenario-grade-calculator-before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-grade-calculator-before.png -------------------------------------------------------------------------------- /docs/images/scenario-noaa-water-level-after.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-noaa-water-level-after.PNG -------------------------------------------------------------------------------- /docs/images/scenario-task-reminders-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-task-reminders-1.png -------------------------------------------------------------------------------- /docs/images/scenario-task-reminders-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-task-reminders-2.png -------------------------------------------------------------------------------- /docs/images/scenario-task-reminders-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-task-reminders-3.png -------------------------------------------------------------------------------- /docs/images/scenario-task-reminders-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-task-reminders-4.png -------------------------------------------------------------------------------- /docs/images/scenario-task-reminders-adaptive-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-task-reminders-adaptive-card.png -------------------------------------------------------------------------------- /docs/images/scenario-task-reminders-spreadsheet-after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-task-reminders-spreadsheet-after.png -------------------------------------------------------------------------------- /docs/images/scenario-task-reminders-spreadsheet-before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/scenario-task-reminders-spreadsheet-before.png -------------------------------------------------------------------------------- /docs/images/schedule-a-script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/schedule-a-script.png -------------------------------------------------------------------------------- /docs/images/schedule-interviews-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/schedule-interviews-1.png -------------------------------------------------------------------------------- /docs/images/schedule-interviews-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/schedule-interviews-2.png -------------------------------------------------------------------------------- /docs/images/schedule-interviews-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/schedule-interviews-3.png -------------------------------------------------------------------------------- /docs/images/schedule-interviews-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/schedule-interviews-4.png -------------------------------------------------------------------------------- /docs/images/script-sharing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/script-sharing.png -------------------------------------------------------------------------------- /docs/images/slicer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/slicer.png -------------------------------------------------------------------------------- /docs/images/table-hyperlink-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/table-hyperlink-view.png -------------------------------------------------------------------------------- /docs/images/table-input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/table-input.png -------------------------------------------------------------------------------- /docs/images/table-of-contents-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/table-of-contents-sample.png -------------------------------------------------------------------------------- /docs/images/table-sample.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/table-sample.PNG -------------------------------------------------------------------------------- /docs/images/teaser-animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/teaser-animation.gif -------------------------------------------------------------------------------- /docs/images/tutorial-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/tutorial-1.png -------------------------------------------------------------------------------- /docs/images/tutorial-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/tutorial-2.png -------------------------------------------------------------------------------- /docs/images/tutorial-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/tutorial-3.png -------------------------------------------------------------------------------- /docs/images/tutorial-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/tutorial-4.png -------------------------------------------------------------------------------- /docs/images/tutorial-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/tutorial-5.png -------------------------------------------------------------------------------- /docs/images/user-input-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/user-input-example.png -------------------------------------------------------------------------------- /docs/images/write-large-dataset-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/write-large-dataset-1.png -------------------------------------------------------------------------------- /docs/images/write-large-dataset-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/write-large-dataset-2.png -------------------------------------------------------------------------------- /docs/images/write-large-dataset-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/write-large-dataset-3.png -------------------------------------------------------------------------------- /docs/images/write-large-dataset-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/write-large-dataset-4.png -------------------------------------------------------------------------------- /docs/images/write-large-dataset-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/write-large-dataset-5.png -------------------------------------------------------------------------------- /docs/images/write-large-dataset-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/write-large-dataset-6.png -------------------------------------------------------------------------------- /docs/images/write-large-dataset-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/write-large-dataset-7.png -------------------------------------------------------------------------------- /docs/images/write-large-dataset-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/write-large-dataset-8.png -------------------------------------------------------------------------------- /docs/images/write-large-dataset-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/images/write-large-dataset-9.png -------------------------------------------------------------------------------- /docs/includes/coding-basics-references.md: -------------------------------------------------------------------------------- 1 | - Learn the basics of JavaScript. You should feel comfortable with concepts like variables, control flow, functions, and data types. [Mozilla offers a good, comprehensive tutorial on JavaScript](https://developer.mozilla.org/docs/Web/JavaScript/Guide/Introduction). 2 | - Learn about types in TypeScript. TypeScript builds on JavaScript by ensuring at compile-time that the right types are used for method calls and assignments. The TypeScript documentation on [object types](https://www.typescriptlang.org/docs/handbook/2/objects.html), [type inference](https://www.typescriptlang.org/docs/handbook/type-inference.html), and [type compatibility](https://www.typescriptlang.org/docs/handbook/type-compatibility.html) will be the most useful. 3 | -------------------------------------------------------------------------------- /docs/includes/external-calls-power-automate.md: -------------------------------------------------------------------------------- 1 | External API calls fail when a script is run through Power Automate. A `fetch` call will give the error message "Runtime error: Line X: fetch is not defined". Be sure to check your scripts for such references before building them into a flow. 2 | 3 | You'll have to use [HTTP with Azure AD](/connectors/webcontents/) or other equivalent actions to pull data from or push it to an external service. 4 | 5 | > [!WARNING] 6 | > External calls made through the Power Automate [Excel Online connector](/connectors/excelonlinebusiness) fail in order to help uphold existing data loss prevention policies. However, scripts that are run through Power Automate are done so outside of your organization, and outside of your organization's firewalls. For additional protection from malicious users in this external environment, your admin can control the use of Office Scripts. Your admin can either disable the Excel Online connector in Power Automate or turn off Office Scripts for Excel through the [Office Scripts administrator controls](/microsoft-365/admin/manage/manage-office-scripts-settings). -------------------------------------------------------------------------------- /docs/includes/platform-requirements.md: -------------------------------------------------------------------------------- 1 | To use Office Scripts, you'll need the following. 2 | 3 | # [For business and education](#tab/business) 4 | 5 | 1. Excel on the web, Excel for Windows (Version 2210 or higher), or Excel for Mac. 6 | 1. OneDrive for Business. 7 | 1. Any of the following Microsoft 365 subscription licenses: 8 | - Office 365 Business 9 | - Office 365 Business Premium 10 | - Office 365 ProPlus 11 | - Office 365 ProPlus for Devices 12 | - Office 365 A3 13 | - Office 365 A5 14 | - Office 365 Enterprise E1 15 | - Office 365 Enterprise E3 16 | - Office 365 Enterprise E5 17 | - Office 365 F3 18 | 1. Internet connectivity with [connected experiences](/deployoffice/privacy/connected-experiences) enabled. 19 | 20 | # [For personal and family](#tab/home) 21 | 22 | > [!IMPORTANT] 23 | > Office Scripts is in preview for personal and family Microsoft 365 subscriptions. If you encounter any issues, please report them through the Feedback button in Excel. 24 | 25 | 1. Excel on the web or Excel for Microsoft 365. 26 | 1. Join the [Microsoft 365 Insider program](https://insider.microsoft365.com/join/windows). 27 | 1. Internet connectivity with [connected experiences](/deployoffice/privacy/connected-experiences) enabled. 28 | 29 | --- 30 | -------------------------------------------------------------------------------- /docs/includes/platform-support-table.md: -------------------------------------------------------------------------------- 1 | | | Excel on the web | Excel for Windows | Excel for Mac | Excel for iOS | Other Office products | Power Automate | 2 | |-|-|-|-|-|-|-| 3 | | **Office Scripts** | Yes | Yes | Yes | No | No | Yes | 4 | | **Office Scripts Action Recorder** | Yes | Yes | Yes | No | No | No | 5 | | **VBA macros** | No | Yes | Yes | No | Yes | No | 6 | | **Office Add-ins** | Yes | Yes | Yes | Yes | Yes | No | 7 | | **COM Add-ins** | No | Yes | No | No | Yes | No | -------------------------------------------------------------------------------- /docs/includes/power-automate-needs-business.md: -------------------------------------------------------------------------------- 1 | > [!IMPORTANT] 2 | > To use Office Scripts in [Power Automate](https://make.powerautomate.com), you must have a [business license of Microsoft 365](../testing/platform-limits.md?tabs=business). The Office 365 Enterprise E1 and Office 365 F3 licenses can use Scripts with Power Automate, but don't have Power Automate integrations directly in Excel. 3 | -------------------------------------------------------------------------------- /docs/includes/power-automate-tutorial-prerequisites.md: -------------------------------------------------------------------------------- 1 | You'll need access to Office Scripts and Power Automate for this tutorial. Please review the [Platform support](/office/dev/scripts/testing/platform-limits#platform-support) if the Automate tab doesn't appear. The [Power Automate sign-up FAQ](/power-automate/organization-q-and-a) has information on getting started with Power Automate. -------------------------------------------------------------------------------- /docs/includes/teams-support-note.md: -------------------------------------------------------------------------------- 1 | > [!IMPORTANT] 2 | > When using Excel with Teams, Office Scripts are only supported in Teams on the web (not Teams for Windows, Mac, iOS, or Android). -------------------------------------------------------------------------------- /docs/includes/tutorial-prerequisites.md: -------------------------------------------------------------------------------- 1 | You'll need access to Office Scripts for this tutorial. Please review the [Platform support](/office/dev/scripts/testing/platform-limits#platform-support) if the Automate tab doesn't appear. 2 | -------------------------------------------------------------------------------- /docs/index.yml: -------------------------------------------------------------------------------- 1 | ### YamlMime:Landing 2 | 3 | title: Office Scripts documentation 4 | summary: Use Office Scripts in Excel to automate your common tasks. Explore the following articles to learn how to create and edit Office Scripts and get started automating today. 5 | 6 | metadata: 7 | title: Office Scripts documentation 8 | description: Resources for learning Office Scripts in Excel, including tutorials, conceptual articles, and code samples. 9 | ms.service: excel 10 | ms.subservice: scripts 11 | ms.topic: landing-page 12 | ms.date: 03/19/2024 13 | ms.localizationpriority: high 14 | 15 | # linkListType: architecture | concept | deploy | download | get-started | how-to-guide | tutorial | overview | quickstart | reference | sample | tutorial | video | whats-new 16 | 17 | landingContent: 18 | # Cards and links should be based on top customer tasks or top subjects 19 | # Start card title with a verb 20 | # Card 21 | - title: About Office Scripts 22 | linkLists: 23 | - linkListType: overview 24 | links: 25 | - text: Code Editor and Action Recorder 26 | url: overview/excel.md 27 | - text: Integrate with Power Automate 28 | url: develop/power-automate-integration.md 29 | - text: Script fundamentals 30 | url: develop/power-automate-integration.md 31 | - linkListType: reference 32 | links: 33 | - text: Office Scripts API reference 34 | url: /javascript/api/office-scripts/overview 35 | 36 | # Card 37 | - title: Get started 38 | linkLists: 39 | - linkListType: tutorial 40 | links: 41 | - text: Create and format a table with Office Scripts 42 | url: tutorials/excel-tutorial.md 43 | - text: Update a spreadsheet from a Power Automate flow 44 | url: tutorials/excel-power-automate-manual.md 45 | - linkListType: sample 46 | links: 47 | - text: Convert CSV files to Excel workbooks 48 | url: resources/samples/convert-csv.md 49 | - text: Set conditional formatting for cross-column comparisons 50 | url: resources/samples/conditional-formatting-parameters.md 51 | - text: Email images of a chart and table 52 | url: resources/samples/email-images-chart-table.md 53 | - text: More samples 54 | url: resources/samples/samples-overview.md 55 | 56 | # Card 57 | - title: Share scripts 58 | linkLists: 59 | - linkListType: how-to-guide 60 | links: 61 | - text: Sharing Office Scripts in Excel 62 | url: https://support.microsoft.com/office/226eddbc-3a44-4540-acfe-fccda3d1122b 63 | - text: Run Scripts from buttons 64 | url: develop/script-buttons.md 65 | - text: Manage Office Scripts admin settings 66 | url: /microsoft-365/admin/manage/manage-office-scripts-settings 67 | -------------------------------------------------------------------------------- /docs/overview/code-editor-environment.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Office Scripts Code Editor environment 3 | description: The prerequisites and environment information for Office Scripts in Excel. 4 | ms.date: 11/01/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Office Scripts Code Editor environment 9 | 10 | Office Scripts are written in either TypeScript or JavaScript and use the Office Scripts JavaScript APIs to interact with an Excel workbook. The Code Editor is based on Visual Studio Code, so if you've used that environment before, you'll feel right at home. 11 | 12 | ## Scripting language: TypeScript or JavaScript 13 | 14 | Office Scripts are written in [TypeScript](https://www.typescriptlang.org/docs/home.html), which is a superset of [JavaScript](https://developer.mozilla.org/docs/Web/JavaScript). The Action Recorder generates code in TypeScript and the Office Scripts documentation uses TypeScript. Since TypeScript is a superset of JavaScript, any scripting code that you write in JavaScript will work just fine. 15 | 16 | Office Scripts are largely self-contained pieces of code. Only a small part of TypeScript's functionality is used. Therefore, you can edit scripts without having to learn the intricacies of TypeScript. The Code Editor also handles the installation, compilation, and execution of code, so you don't need to worry about anything but the script itself. It's possible to learn the language and create scripts without previous programming knowledge. However, if you're new to programming, we recommend learning some fundamentals before proceeding with Office Scripts. 17 | 18 | [!INCLUDE [Recommended coding resources](../includes/coding-basics-references.md)] 19 | 20 | ## Office Scripts JavaScript API 21 | 22 | Office Scripts use a specialized version of the Office JavaScript APIs for [Office Add-ins](/office/dev/add-ins/overview/index). While there are similarities in the two APIs, you should not assume code can be ported between the two platforms. The differences between the two platforms are described in the [Differences between Office Scripts and Office Add-ins](../resources/add-ins-differences.md#apis) article. You can view all the APIs available to your script in the [Office Scripts API reference documentation](/javascript/api/office-scripts/overview). 23 | 24 | ## External library support 25 | 26 | Office Scripts does not support the usage of external, third-party JavaScript libraries. Currently, you cannot call any library other than the Office Scripts APIs from a script. You do still have access to any [built-in JavaScript object](../develop/javascript-objects.md), such as [Math](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math). 27 | 28 | ## IntelliSense 29 | 30 | IntelliSense is a set of Code Editor features that help you write code. It provides auto-complete, syntax error highlighting, and inline API documentation. 31 | 32 | IntelliSense gives suggestions as you type, similar to the suggested text in Excel. Pressing the Tab or Enter key inserts the suggested member. Trigger IntelliSense at the current cursor location by pressing the Ctrl+Space keys. These suggestions are especially useful when completing a method. The method signature displayed by IntelliSense contains a list of arguments it needs, each argument's type, whether a given argument is required or optional, and the return type of the method. 33 | 34 | Hover the cursor over a method, class, or other code object to see more information. Hover over a syntax error or code suggestion, represented by a red or yellow squiggly line, to see suggestions on how to fix the problem. Often, IntelliSense provides a "Quick Fix" option to automatically change the code. 35 | 36 | :::image type="content" source="../images/implicit-any-editor-message.png" alt-text="An error message in the Code Editor's hover text with a 'Quick Fix' button."::: 37 | 38 | The Office Scripts Code Editor uses the same IntelliSense engine as Visual Studio Code. To learn more about the feature, visit [Visual Studio Code's IntelliSense Features](https://code.visualstudio.com/docs/editor/intellisense#_intellisense-features). 39 | 40 | ## Keyboard shortcuts 41 | 42 | Most of the keyboard shortcuts for Visual Studio Code also work in the Office Scripts Code Editor. Use the following PDFs to learn about the available options and get the most out of the Code Editor: 43 | 44 | - [Keyboard shortcuts for macOS](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf). 45 | - [Keyboard shortcuts for Windows](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf). 46 | 47 | ## See also 48 | 49 | - [Office Scripts API reference](/javascript/api/office-scripts/overview) 50 | - [Troubleshooting Office Scripts](../testing/troubleshooting.md) 51 | - [Using built-in JavaScript objects in Office Scripts](../develop/javascript-objects.md) 52 | -------------------------------------------------------------------------------- /docs/resources/add-ins-differences.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Differences between Office Scripts and Office Add-ins 3 | description: The behavior and API differences between Office Scripts and Office Add-ins. 4 | ms.topic: product-comparison 5 | ms.date: 02/13/2023 6 | ms.localizationpriority: medium 7 | --- 8 | 9 | # Differences between Office Scripts and Office Add-ins 10 | 11 | Understand the differences between Office Scripts and Office Add-ins to know when to use each one. Office Scripts are designed to be quickly made by anyone looking to improve their workflow. Office Add-ins integrate with the Office UI for a more interactive experience through ribbon buttons and task panes. Office Add-ins can also expand built-in Excel functions by providing custom functions. 12 | 13 | :::image type="content" source="../images/office-programmability-diagram.png" alt-text="A four-quadrant diagram showing the focus areas for different Office extensibility solutions. Both Office Scripts and Office Web Add-ins are focused on cross-platform experiences and collaboration. Office Scripts cater to end users, whereas Office Web Add-ins target professional developers."::: 14 | 15 | Office Scripts run to completion with a manual button selection or as a step in [Power Automate](https://make.powerautomate.com/), whereas Office Add-ins continue running depending on how they are configured. For example, you can configure an Office Add-in to continue running even when its task pane is closed. This means that Office Add-ins maintain state during a session, whereas Office Scripts don't maintain an internal state between runs. If the solution you're building requires a maintained state, you should visit the [Office Add-ins documentation](/office/dev/add-ins) to learn more about Office Add-ins. 16 | 17 | The rest of this article describes on the main differences between Office Add-ins and Office Scripts. 18 | 19 | ## Platform support 20 | 21 | The following table shows which features are supported by which platforms and products. 22 | 23 | [!INCLUDE [Platform support table](../includes/platform-support-table.md)] 24 | 25 | ## APIs 26 | 27 | While the Office JavaScript APIs for Office Add-ins and the Office Scripts APIs share some functionality, they are different platforms. The Office Scripts APIs are an optimized, synchronous subset of the Excel JavaScript API model. The major difference is usage of the `load`/`sync` paradigm with add-ins. Additionally, add-ins offer APIs for events and a broader set of functionality outside of Excel, known as the Common APIs. 28 | 29 | Office Add-ins offer greater connectivity to external web services and libraries. Office Scripts are limited to [specific external calls](../develop/external-calls.md). 30 | 31 | ### Events 32 | 33 | Office Scripts do not support workbook-level [events](/office/dev/add-ins/excel/excel-add-ins-events). Scripts are either triggered by users selecting the **Run** button for a script or through Power Automate. Every script runs the code in a single `main` function, then ends. 34 | 35 | ### UX and UI controls 36 | 37 | Office Scripts can only interact with the workbook, not the task pane. If you need authentication, dialog windows, or additional UX and UI controls, you'll need to create an Office Add-in instead of an Office Script. 38 | 39 | ## See also 40 | 41 | - [Office Scripts in Excel](../overview/excel.md) 42 | - [Differences between Office Scripts and VBA macros](vba-differences.md) 43 | - [Troubleshooting Office Scripts](../testing/troubleshooting.md) 44 | - [Build an Excel task pane add-in](/office/dev/add-ins/quickstarts/excel-quickstart-jquery) 45 | -------------------------------------------------------------------------------- /docs/resources/power-query-differences.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: When to use Power Query or Office Scripts 3 | description: The scenarios that are best suited for both the Power Query and Office Scripts platforms. 4 | ms.topic: product-comparison 5 | ms.date: 10/01/2022 6 | ms.localizationpriority: medium 7 | --- 8 | 9 | # When to use Power Query or Office Scripts 10 | 11 | [Power Query](https://powerquery.microsoft.com) and Office Scripts are both powerful automation solutions for Excel. Both solutions let Excel users clean and transform data in workbooks. A single Power Query or Office Script can be refreshed and rerun on new data to produce consistent results, which saves you time and lets you work with the resulting information faster. 12 | 13 | This article provides a general overview of when you might favor one platform over the other. In general, Power Query is good for pulling and transforming data from large, external data sources and Office Scripts are good for quick, Excel-centric solutions and [Power Automate integrations](../develop/power-automate-integration.md). 14 | 15 | ## Large data sources and data retrieval: Power Query 16 | 17 | We recommend Power Query when dealing with data sources from supported platforms. 18 | 19 | Power Query has [built-in data connections](https://powerquery.microsoft.com/connectors/) to hundreds of sources. Power Query is specially designed for data retrieval, transformation, and combination tasks. When you need data from one of those sources, Power Query gives you a no-code way of bringing that data into Excel in the shape you need. 20 | 21 | These Power Query connections are designed for large datasets. They do not have the same [transfer limits](../testing/platform-limits.md) as Power Automate or Excel on the web. 22 | 23 | Office Scripts offer a lightweight solution for smaller data sources or data sources not covered by Power Query connectors. This includes [using `fetch` or REST APIs](../develop/external-calls.md) or getting information from ad-hoc data sources, such as a [Teams adaptive card](../resources/scenarios/task-reminders.md). 24 | 25 | ## Formatting, visualizations, and programmatic control: Office Scripts 26 | 27 | We recommend Office Scripts when your needs go beyond data importing and transformation. 28 | 29 | Nearly everything you can do manually through the Excel UI is doable with Office Scripts. They're great for applying consistent formatting to workbooks. Scripts create charts, PivotTables, shapes, images, and other worksheet visualizations. Scripts also give you precise control over the positions, sizes, colors, and other attributes of these visualizations. 30 | 31 | The inclusion of TypeScript code gives you a high degree of customization. Programmatic control logic like `if...else` statements makes your script robust. This lets you do things like conditionally read data without relying on complex Excel formulas, or scan the workbook for unexpected changes before changing the workbook. 32 | 33 | Formatting can be applied with Power Query through Excel [templates](https://templates.office.com/power-query-tutorial-tm11414620). However, templates are updated at the individual or organization level, whereas Office Scripts offer more granular access control. 34 | 35 | ## Power Automate integrations 36 | 37 | Office Scripts offer more options for Power Automate integration. Scripts are tailored to your solutions. You define the [input and output of the script](../develop/power-automate-integration.md#data-transfer-in-flows-for-scripts), so it works with any other connector or data in the flow. The following screenshot shows an example Power Automate flow that passes data from a Teams Adaptive Card to an Office Script. 38 | 39 | :::image type="content" source="../images/scenario-task-reminders-3.png" alt-text="A screenshot that shows the Excel Online (Business) connector in the flow designer. The connector is using the Run script action to take input from a Teams Adaptive Card and provide it to a script."::: 40 | 41 | Power Query is used in the [SQL Server](https://powerquery.microsoft.com/flow/) Power Automate connector. The [Transform data using Power Query](/connectors/sql/#transform-data-using-power-query) action lets you build a query in Power Automate. While this is a powerful tool for use with SQL Server, it does limit Power Query to that input source, as shown in the following flow screenshot. 42 | 43 | :::image type="content" source="../images/power-query-flow-option.png" alt-text="A screenshot that shows the SQL Server connector in the flow designer. The connector is using the Transform data using Power Query action."::: 44 | 45 | ## Platform dependencies 46 | 47 | Office Scripts is currently available for Excel on the web, Excel for Windows, and Excel for Mac. The full Power Query experience is currently [only available for Excel for Windows](/power-query/power-query-what-is-power-query#where-can-you-use-power-query). Both can be used through Power Automate, which lets the flow work with Excel workbooks stored in OneDrive. 48 | 49 | ## See also 50 | 51 | - [Power Query Portal](https://powerquery.microsoft.com/) 52 | - [Power Query with Excel](https://powerquery.microsoft.com/excel/) 53 | - [Run Office Scripts with Power Automate](../develop/power-automate-integration.md) 54 | -------------------------------------------------------------------------------- /docs/resources/samples/add-excel-comments.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Notify people with comments 3 | description: Learn how to use Office Scripts to add comments in a worksheet that notify users with @mentions. 4 | ms.date: 12/05/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Notify people with comments 9 | 10 | This sample shows how to add comments to a cell including [@mentioning](https://support.microsoft.com/office/90701709-5dc1-41c7-aa48-b01d4a46e8c7) a colleague. 11 | 12 | ## Example scenario 13 | 14 | The team lead maintains the shift schedule. They assign an employee ID to the shift record. If the team lead wishes to notify the employee, they add a comment that @mentions the employee. The employee is emailed with a custom message from the worksheet. Subsequently, the employee can view the workbook and respond to the comment at their convenience. 15 | 16 | ## Solution 17 | 18 | 1. The script extracts employee information from the employee worksheet. 19 | 1. The script then adds a comment (including the relevant employee email) to the appropriate cell in the shift record. 20 | 1. Existing comments in the cell are removed before adding the new comment. 21 | 22 | ## Setup: Sample Excel file 23 | 24 | This workbook contains the data, objects, and formatting expected by the script. 25 | 26 | > [!div class="nextstepaction"] 27 | > [Download the sample workbook](add-excel-comments.xlsx) 28 | 29 | ## Sample code: Add comments 30 | 31 | Add the following script to the sample workbook and try the sample yourself! 32 | 33 | ```TypeScript 34 | function main(workbook: ExcelScript.Workbook) { 35 | // Get the list of employees. 36 | const employees = workbook.getWorksheet('Employees').getUsedRange().getTexts(); 37 | 38 | // Get the schedule information from the schedule table. 39 | const scheduleSheet = workbook.getWorksheet('Schedule'); 40 | const table = scheduleSheet.getTables()[0]; 41 | const range = table.getRangeBetweenHeaderAndTotal(); 42 | const scheduleData = range.getTexts(); 43 | 44 | // Find old comments, so we can delete them later. 45 | const oldCommentAddresses = scheduleSheet.getComments().map(oldComment => oldComment.getLocation().getAddress()); 46 | 47 | // Look through the schedule for a matching employee. 48 | for (let i = 0; i < scheduleData.length; i++) { 49 | const employeeId = scheduleData[i][3]; 50 | 51 | // Compare the employee ID in the schedule against the employee information table. 52 | const employeeInfo = employees.find(employeeRow => employeeRow[0] === employeeId); 53 | if (employeeInfo) { 54 | const adminNotes = scheduleData[i][4]; 55 | const commentCell = range.getCell(i, 5); 56 | 57 | // Delete old comments, so we avoid conflicts. 58 | if (oldCommentAddresses.find(oldCommentAddress => oldCommentAddress === commentCell.getAddress())) { 59 | const comment = workbook.getCommentByCell(commentCell); 60 | comment.delete(); 61 | } 62 | 63 | // Add a comment using the admin notes as the text. 64 | workbook.addComment(commentCell, { 65 | mentions: [{ 66 | email: employeeInfo[1], 67 | id: 0, // This ID maps this mention to the `id=0` text in the comment. 68 | name: employeeInfo[2] 69 | }], 70 | richContent: `${employeeInfo[2]} ${adminNotes}` 71 | }, ExcelScript.ContentType.mention); 72 | } else { 73 | console.log("No match for: " + employeeId); 74 | } 75 | } 76 | } 77 | ``` 78 | -------------------------------------------------------------------------------- /docs/resources/samples/add-excel-comments.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/add-excel-comments.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/add-image-to-workbook.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Add images to a workbook 3 | description: Learn how to use Office Scripts to add an image to a workbook and copy it across sheets. 4 | ms.date: 04/27/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Add images to a workbook 9 | 10 | This sample shows how to work with images using an Office Script in Excel. 11 | 12 | ## Scenario 13 | 14 | Images help with branding, visual identity, and templates. They help make a workbook more than just a giant table. 15 | 16 | The first sample copies an image from one worksheet to another. This could be used to put your company's logo in the same position on every sheet. 17 | 18 | The second sample copies an image from a URL. This could be used to copy photos that a colleague stored in a shared folder to a related workbook. Please note that this sample can't be adapted to work with a local image file, as that isn't supported by Office Scripts. 19 | 20 | ## Setup: Sample Excel file 21 | 22 | This workbook contains the data, objects, and formatting expected by the script. 23 | 24 | > [!div class="nextstepaction"] 25 | > [Download the sample workbook](add-images.xlsx) 26 | 27 | ## Sample code: Copy an image across worksheets 28 | 29 | Add the following script to the sample workbook and try the sample yourself! 30 | 31 | ```TypeScript 32 | /** 33 | * This script transfers an image from one worksheet to another. 34 | */ 35 | function main(workbook: ExcelScript.Workbook) 36 | { 37 | // Get the worksheet with the image on it. 38 | let firstWorksheet = workbook.getWorksheet("FirstSheet"); 39 | 40 | // Get the first image from the worksheet. 41 | // If a script added the image, you could add a name to make it easier to find. 42 | let image: ExcelScript.Image; 43 | firstWorksheet.getShapes().forEach((shape, index) => { 44 | if (shape.getType() === ExcelScript.ShapeType.image) { 45 | image = shape.getImage(); 46 | return; 47 | } 48 | }); 49 | 50 | // Copy the image to another worksheet. 51 | image.getShape().copyTo("SecondSheet"); 52 | } 53 | ``` 54 | 55 | ## Sample code: Add an image from a URL to a workbook 56 | 57 | > [!IMPORTANT] 58 | > This sample won't work in Power Automate because of the [`fetch` call](../../develop/external-calls.md#external-calls-from-power-automate). 59 | 60 | ```TypeScript 61 | async function main(workbook: ExcelScript.Workbook) { 62 | // Fetch the image from a URL. 63 | const link = "https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/master/docs/images/git-octocat.png"; 64 | const response = await fetch(link); 65 | 66 | // Store the response as an ArrayBuffer, since it is a raw image file. 67 | const data = await response.arrayBuffer(); 68 | 69 | // Convert the image data into a base64-encoded string. 70 | const image = convertToBase64(data); 71 | 72 | // Add the image to a worksheet. 73 | workbook.getWorksheet("WebSheet").addImage(image); 74 | } 75 | 76 | /** 77 | * Converts an ArrayBuffer containing a .png image into a base64-encoded string. 78 | */ 79 | function convertToBase64(input: ArrayBuffer) { 80 | const uInt8Array = new Uint8Array(input); 81 | const count = uInt8Array.length; 82 | 83 | // Allocate the necessary space up front. 84 | const charCodeArray = new Array(count) as string[]; 85 | 86 | // Convert every entry in the array to a character. 87 | for (let i = count; i >= 0; i--) { 88 | charCodeArray[i] = String.fromCharCode(uInt8Array[i]); 89 | } 90 | 91 | // Convert the characters to base64. 92 | const base64 = btoa(charCodeArray.join('')); 93 | return base64; 94 | } 95 | ``` 96 | -------------------------------------------------------------------------------- /docs/resources/samples/add-images.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/add-images.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/automate-tasks-on-all-excel-files-in-folder.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Run a script on all Excel files in a folder 3 | description: Learn how to run a script on all the Excel files in a folder on OneDrive for Business. 4 | ms.date: 11/30/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Run a script on all Excel files in a folder 9 | 10 | This project performs a set of automation tasks on all files situated in a folder on OneDrive for Business. It could also be used on a SharePoint folder. 11 | It performs calculations on the Excel files, adds formatting, and inserts a comment that [@mentions](https://support.microsoft.com/office/90701709-5dc1-41c7-aa48-b01d4a46e8c7) a colleague. 12 | 13 | ## Sample Excel files 14 | 15 | Download highlight-alert-excel-files.zip for all the workbooks you'll need for this sample. Extract those files to a folder titled **Sales**. Add the following script to your script collection to try the sample yourself! 16 | 17 | ## Sample code: Add formatting and insert comment 18 | 19 | This is the script that runs on each individual workbook. In Excel, use **Automate** > **New Script** to paste the code and save the script. Save it as **Review script** and try the sample yourself! 20 | 21 | ```TypeScript 22 | function main(workbook: ExcelScript.Workbook) { 23 | // Get the table named "Table1" in the workbook. 24 | const table1 = workbook.getTable("Table1"); 25 | 26 | // If the table is empty, end the script. 27 | const rowCount = table1.getRowCount(); 28 | if (rowCount === 0) { 29 | return; 30 | } 31 | 32 | // Force the workbook to be completely recalculated. 33 | workbook.getApplication().calculate(ExcelScript.CalculationType.full); 34 | 35 | // Get the "Amount Due" column from the table. 36 | const amountDueColumn = table1.getColumnByName('Amount Due'); 37 | const amountDueValues = amountDueColumn.getRangeBetweenHeaderAndTotal().getValues(); 38 | 39 | // Find the highest amount that's due. 40 | let highestValue = amountDueValues[0][0]; 41 | let row = 0; 42 | for (let i = 1; i < amountDueValues.length; i++) { 43 | if (amountDueValues[i][0] > highestValue) { 44 | highestValue = amountDueValues[i][0]; 45 | row = i; 46 | } 47 | } 48 | 49 | let highestAmountDue = table1.getColumn("Amount due").getRangeBetweenHeaderAndTotal().getRow(row); 50 | 51 | // Set the fill color to yellow for the cell with the highest value in the "Amount Due" column. 52 | highestAmountDue.getFormat().getFill().setColor("FFFF00"); 53 | 54 | // Insert an @mention comment in the cell. 55 | workbook.addComment(highestAmountDue, { 56 | mentions: [{ 57 | email: "AdeleV@M365x904181.OnMicrosoft.com", 58 | id: 0, 59 | name: "Adele Vance" 60 | }], 61 | richContent: "Adele Vance Please review this amount" 62 | }, ExcelScript.ContentType.mention); 63 | } 64 | ``` 65 | 66 | ## Power Automate flow: Run the script on every workbook in the folder 67 | 68 | This flow runs the script on every workbook in the "Sales" folder. 69 | 70 | 1. Create a new **Instant cloud flow**. 71 | 1. Choose **Manually trigger a flow** and select **Create**. 72 | 1. In the flow builder, select the **+** button and **Add an action**. Use the **OneDrive for Business** connector's **List files in folder** action. Use the following values for the action. 73 | * **Folder**: /Sales (selected by the file picker) 74 | 75 | :::image type="content" source="../../images/all-files-in-folder-sample-flow-1.png" alt-text="The completed OneDrive for Business connector in Power Automate."::: 76 | 77 | 1. Ensure only workbooks are selected. Add a new **Condition** control action. Use the following values for the condition. 78 | * **Choose a value**: Name (_dynamic content from **List files in folder**_) 79 | * **ends with**: (from the dropdown list) 80 | * **Choose a value**: .xlsx 81 | 82 | :::image type="content" source="../../images/all-files-in-folder-sample-flow-2.png" alt-text="The Power Automate condition block that applies subsequent actions to each file."::: 83 | 84 | 1. Under the **True** branch, add a new action. Select the **Excel Online (Business)** connector's **Run script** action. Use the following values for the action. 85 | * **Location**: OneDrive for Business 86 | * **Document Library**: OneDrive 87 | * **File**: Id (_dynamic content from **List files in folder**_) 88 | * **Script**: Review script 89 | 90 | :::image type="content" source="../../images/all-files-in-folder-sample-flow-3.png" alt-text="The completed Excel Online (Business) connector in Power Automate."::: 91 | 92 | 1. Save the flow. The flow designer should look like the following image. 93 | 94 | :::image type="content" source="../../images/all-files-in-folder-sample-flow-4.png" alt-text="A diagram of the completed flow that shows two steps before a condition and one step under the true path of the condition."::: 95 | 96 | 1. Try it out! Use the **Test** button on the flow editor page or run the flow through your **My flows** tab. Be sure to allow access when prompted. 97 | 98 | ## Training video: Run a script on all Excel files in a folder 99 | 100 | [Watch Sudhi Ramamurthy walk through this sample on YouTube](https://youtu.be/xMg711o7k6w). 101 | -------------------------------------------------------------------------------- /docs/resources/samples/community-seasons-greetings.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Seasons greetings 3 | description: Learn how to use Office Scripts to show a singing tree in Excel. 4 | ms.date: 06/29/2021 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Seasons greetings 9 | 10 | This script was contributed by [Leslie Black](https://www.linkedin.com/in/lesblackconsultant/) in the spirit of the holiday season! It's a fun script that shows a singing tree in Excel using Office Scripts. 11 | 12 | Enjoy! 13 | 14 | [Watch the Seasons greetings script in action on the "Les's IT Blog" YouTube channel](https://youtu.be/HBiGEkzmkgo). 15 | 16 | ## Setup: Sample Excel file 17 | 18 | This workbook contains the data, objects, and formatting expected by the script. 19 | 20 | > [!div class="nextstepaction"] 21 | > [Download the sample workbook](happy-tree.xlsx) 22 | 23 | ## Sample code: Happy tree 24 | 25 | Add the following script to the sample workbook and try the sample yourself! 26 | 27 | ```TypeScript 28 | /* Original version by Leslie Black. */ 29 | 30 | function main(workbook: ExcelScript.Workbook) { 31 | let happyTree = workbook.getWorksheet('HappyTree'); 32 | happyTree.activate(); 33 | 34 | setOuterEdgeYellow(workbook) //yellow 35 | setOuterEdgeRed(workbook) //red 36 | setOuterEdgeYellow(workbook) //yellow 37 | setOuterEdgeRed(workbook) //red 38 | setOuterEdgeYellow(workbook) //yellow 39 | setOuterEdgeRed(workbook) //red 40 | setOuterEdgeYellow(workbook) //yellow 41 | setOuterEdgeRed(workbook) //red 42 | setOuterEdgeYellow(workbook) //yellow 43 | setOuterEdgeRed(workbook) //red 44 | setOuterEdgeYellow(workbook) //yellow 45 | setOuterEdgeRed(workbook) //red 46 | setOuterEdgeYellow(workbook) //yellow 47 | setOuterEdgeRed(workbook) //red 48 | setOuterEdgeYellow(workbook) //yellow 49 | setOuterEdgeRed(workbook) //red 50 | setOuterEdgeYellow(workbook) //yellow 51 | setFlashingStarAndSmileRed(workbook) //red 52 | setFlashingStarAndSmileYellow(workbook) //yellow 53 | 54 | setOuterEdgeYellow(workbook) //yellow 55 | setOuterEdgeRed(workbook) //red 56 | setOuterEdgeYellow(workbook) //yellow 57 | setOuterEdgeRed(workbook) //red 58 | setOuterEdgeYellow(workbook) //yellow 59 | setOuterEdgeRed(workbook) //red 60 | setOuterEdgeYellow(workbook) //yellow 61 | setOuterEdgeRed(workbook) //red 62 | setOuterEdgeYellow(workbook) //yellow 63 | setOuterEdgeRed(workbook) //red 64 | setOuterEdgeYellow(workbook) //yellow 65 | setOuterEdgeRed(workbook) //red 66 | setOuterEdgeYellow(workbook) //yellow 67 | setOuterEdgeRed(workbook) //red 68 | setOuterEdgeYellow(workbook) //yellow 69 | setOuterEdgeRed(workbook) //red 70 | setOuterEdgeYellow(workbook) //yellow 71 | setFlashingStarAndSmileRed(workbook) //red 72 | setFlashingStarAndSmileYellow(workbook) //yellow 73 | blink(workbook) 74 | 75 | setOuterEdgeRed(workbook) //red 76 | setOuterEdgeYellow(workbook) //yellow 77 | 78 | setOuterEdgeRed(workbook) //red 79 | setOuterEdgeYellow(workbook) //yellow 80 | 81 | setOuterEdgeRed(workbook) //red 82 | setOuterEdgeYellow(workbook) //yellow 83 | unblink(workbook) 84 | 85 | console.log('Routine finished'); 86 | 87 | function blink(workbook: ExcelScript.Workbook) { 88 | let selectedSheet = workbook.getWorksheet('HappyTree'); 89 | // Set the eyes to brown. 90 | selectedSheet.getRanges("N16:Q17, G16: J17") 91 | .getFormat() 92 | .getFill() 93 | .setColor("C65911"); 94 | } 95 | 96 | function unblink(workbook: ExcelScript.Workbook) { 97 | let selectedSheet = workbook.getWorksheet('HappyTree'); 98 | // Set the eyes back to white (except the pupils). 99 | selectedSheet.getRanges("N16:N17, O16:Q16, G16:H17, I16:J16, P17:Q17, J17") 100 | .getFormat() 101 | .getFill() 102 | .setColor("FFFFFF"); 103 | } 104 | 105 | function setFlashingStarAndSmileRed(workbook: ExcelScript.Workbook) { 106 | // Set the star to red. 107 | let selectedSheet = workbook.getWorksheet('HappyTree'); 108 | selectedSheet.getRanges("L2:L6, K3:K5, M3:M5, N4, J4") 109 | .getFormat() 110 | .getFill() 111 | .setColor("FF0000"); 112 | // Set the smile points to black. 113 | selectedSheet.getRanges("I26, O26") 114 | .getFormat() 115 | .getFill() 116 | .setColor("000000"); 117 | } 118 | 119 | function setFlashingStarAndSmileYellow(workbook: ExcelScript.Workbook) { 120 | // Set the start to yellow. 121 | let selectedSheet = workbook.getWorksheet('HappyTree'); 122 | selectedSheet.getRanges("L2:L6, K3:K5, M3:M5, N4, J4") 123 | .getFormat() 124 | .getFill() 125 | .setColor("FFFF00"); 126 | // Clear the smile points. 127 | selectedSheet.getRanges("O26, I26") 128 | .getFormat() 129 | .getFill().clear(); 130 | } 131 | } 132 | 133 | function setOuterEdgeYellow(workbook: ExcelScript.Workbook) { 134 | let sheet = workbook.getWorksheet('HappyTree'); 135 | // Set the outer edge to yellow. 136 | sheet.getRanges("Q11, G11, R12, F12, S13, E13, T14, D14, C15, U15, T16:T17, D16:D17, C18, U18, T19, D19, L2:L6, C21, U21, C23, U23, C25, U25, C27, U27, C29, U29, T30, D30, K3:K5, M3: M5, S31, E31, R32, F32, Q33, G33, P34, H34, O35, I35, N36:N37, J36:J37, K37:M37, N4, J4, K7, M7, N8, J8, O9, I9, P10, H10") 137 | .getFormat() 138 | .getFill() 139 | .setColor("FFFF00"); 140 | } 141 | 142 | function setOuterEdgeRed(workbook: ExcelScript.Workbook) { 143 | let sheet = workbook.getWorksheet('HappyTree'); 144 | // Set the outer edge to red. 145 | sheet.getRanges("Q11, G11, R12, F12, S13, E13, T14, D14, C15, U15, T16:T17, D16:D17, C18, U18, T19, D19, L2:L6, C21, U21, C23, U23, C25, U25, C27, U27, C29, U29, T30, D30, K3:K5, M3: M5, S31, E31, R32, F32, Q33, G33, P34, H34, O35, I35, N36:N37, J36:J37, K37:M37, N4, J4, K7, M7, N8, J8, O9, I9, P10, H10") 146 | .getFormat() 147 | .getFill() 148 | .setColor("FF0000"); 149 | } 150 | ``` 151 | -------------------------------------------------------------------------------- /docs/resources/samples/conditional-formatting-parameters.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Set conditional formatting for cross-column comparisons 3 | description: Learn how to apply conditional formatting and get input from the user. 4 | ms.date: 09/07/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Set conditional formatting for cross-column comparisons 9 | 10 | This sample shows how to apply conditional formatting to a range. The conditions used are comparing values to those in an adjacent column. Additionally, this sample uses [parameters to get user input](../../develop/user-input.md). This lets the person running the script select the range, the type of comparison, and the colors. 11 | 12 | ## Sample code: Set conditional formatting 13 | 14 | ```TypeScript 15 | /** 16 | * Formats a range on the current sheet based on values in an adjacent column. 17 | * @param rangeAddress The A1-notation range to format. 18 | * @param compareTo The adjacent column to compare against. 19 | * @param colorIfGreater The color of the cell if the value is greater than the adjacent column. 20 | * @param colorIfEqual The color of the cell if the value is equal to the adjacent column. 21 | * @param colorIfLess The color of the cell if the value is less than the adjacent column. 22 | */ 23 | function main( 24 | workbook: ExcelScript.Workbook, 25 | rangeAddress: string, compareTo: "Left" | "Right", 26 | colorIfGreater: "Red" | "Green" | "Yellow" | "None", 27 | colorIfLess: "Red" | "Green" | "Yellow" | "None", 28 | colorIfEqual: "Red" | "Green" | "Yellow" | "None" 29 | ) { 30 | // Get the specified range. 31 | const selectedSheet = workbook.getActiveWorksheet(); 32 | const range = selectedSheet.getRange(rangeAddress); 33 | 34 | // Remove old conditional formatting. 35 | range.clearAllConditionalFormats(); 36 | 37 | // Get the address of the first adjacent cell of the adjacent column. 38 | let adjacentColumn: string; 39 | if (compareTo == "Left") { 40 | adjacentColumn = range.getColumnsBefore().getCell(0, 0).getAddress(); 41 | } else { 42 | adjacentColumn = range.getColumnsAfter().getCell(0, 0).getAddress(); 43 | } 44 | 45 | // Remove the worksheet name from the address to create a relative formula. 46 | let formula = "=$" + adjacentColumn.substring(adjacentColumn.lastIndexOf("!") + 1); 47 | 48 | // Set the conditional formatting based on the user's color choices. 49 | setConditionalFormatting( 50 | range.addConditionalFormat(ExcelScript.ConditionalFormatType.cellValue).getCellValue(), 51 | colorIfGreater, 52 | formula, 53 | ExcelScript.ConditionalCellValueOperator.greaterThan); 54 | setConditionalFormatting( 55 | range.addConditionalFormat(ExcelScript.ConditionalFormatType.cellValue).getCellValue(), 56 | colorIfEqual, 57 | formula, 58 | ExcelScript.ConditionalCellValueOperator.equalTo); 59 | setConditionalFormatting( 60 | range.addConditionalFormat(ExcelScript.ConditionalFormatType.cellValue).getCellValue(), 61 | colorIfLess, 62 | formula, 63 | ExcelScript.ConditionalCellValueOperator.lessThan); 64 | } 65 | 66 | function setConditionalFormatting( 67 | conditionalFormat: ExcelScript.CellValueConditionalFormat, 68 | color: "Red" | "Green" | "Yellow" | "None", 69 | formula: string, 70 | operator: ExcelScript.ConditionalCellValueOperator 71 | ) { 72 | // Pick the fill and font colors based on the preset color choices. 73 | if (color == "Red") { 74 | conditionalFormat.getFormat().getFont().setColor("#9C0006"); 75 | conditionalFormat.getFormat().getFill().setColor("#FFC7CE"); 76 | } else if (color == "Green") { 77 | conditionalFormat.getFormat().getFont().setColor("#001600"); 78 | conditionalFormat.getFormat().getFill().setColor("#C6EFCE"); 79 | } else if (color == "Yellow") { 80 | conditionalFormat.getFormat().getFont().setColor("#9C5700"); 81 | conditionalFormat.getFormat().getFill().setColor("#FFEB9C"); 82 | } else { /* None */ 83 | return; 84 | } 85 | 86 | // Apply the conditional formatting. 87 | conditionalFormat.setRule({ 88 | formula1: formula, 89 | operator: operator 90 | }); 91 | } 92 | ``` 93 | -------------------------------------------------------------------------------- /docs/resources/samples/conditional-formatting-samples.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/conditional-formatting-samples.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/convert-csv-example.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/convert-csv-example.zip -------------------------------------------------------------------------------- /docs/resources/samples/copy-tables-combine.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Combine data from multiple Excel tables into a single table 3 | description: Learn how to use Office Scripts to combine data from multiple Excel tables into a single table. 4 | ms.date: 06/29/2021 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Combine data from multiple Excel tables into a single table 9 | 10 | This sample combines data from multiple Excel tables into a single table that includes all the rows. It assumes that all tables being used have the same structure. 11 | 12 | There are two variations of this script: 13 | 14 | 1. The [first script](#sample-code-combine-data-from-multiple-excel-tables-into-a-single-table) combines all tables in the Excel file. 15 | 1. The [second script](#sample-code-combine-data-from-multiple-excel-tables-in-select-worksheets-into-a-single-table) selectively gets tables within a set of worksheets. 16 | 17 | ## Setup: Sample Excel file 18 | 19 | This workbook contains the data, objects, and formatting expected by the script. 20 | 21 | > [!div class="nextstepaction"] 22 | > [Download the sample workbook](tables-copy.xlsx) 23 | 24 | ## Sample code: Combine data from multiple Excel tables into a single table 25 | 26 | Add the following script to the sample workbook and try the sample yourself! 27 | 28 | ```TypeScript 29 | function main(workbook: ExcelScript.Workbook) { 30 | // Delete the "Combined" worksheet, if it's present. 31 | workbook.getWorksheet('Combined')?.delete(); 32 | 33 | // Create a new worksheet named "Combined" for the combined table. 34 | const newSheet = workbook.addWorksheet('Combined'); 35 | 36 | // Get the header values for the first table in the workbook. 37 | // This also saves the table list before we add the new, combined table. 38 | const tables = workbook.getTables(); 39 | const headerValues = tables[0].getHeaderRowRange().getTexts(); 40 | console.log(headerValues); 41 | 42 | // Copy the headers on a new worksheet to an equal-sized range. 43 | const targetRange = newSheet.getRange('A1').getResizedRange(headerValues.length-1, headerValues[0].length-1); 44 | targetRange.setValues(headerValues); 45 | 46 | // Add the data from each table in the workbook to the new table. 47 | const combinedTable = newSheet.addTable(targetRange.getAddress(), true); 48 | for (let table of tables) { 49 | let dataValues = table.getRangeBetweenHeaderAndTotal().getTexts(); 50 | let rowCount = table.getRowCount(); 51 | 52 | // If the table is not empty, add its rows to the combined table. 53 | if (rowCount > 0) { 54 | combinedTable.addRows(-1, dataValues); 55 | } 56 | } 57 | } 58 | ``` 59 | 60 | ## Sample code: Combine data from multiple Excel tables in select worksheets into a single table 61 | 62 | Download the sample file [tables-select-copy.xlsx](tables-select-copy.xlsx) and use it with the following script to try it out yourself! 63 | 64 | ```TypeScript 65 | function main(workbook: ExcelScript.Workbook) { 66 | // Set the worksheet names to get tables from. 67 | const sheetNames = ['Sheet1', 'Sheet2', 'Sheet3']; 68 | 69 | // Delete the "Combined" worksheet, if it's present. 70 | workbook.getWorksheet('Combined')?.delete(); 71 | 72 | // Create a new worksheet named "Combined" for the combined table. 73 | const newSheet = workbook.addWorksheet('Combined'); 74 | 75 | // Create a new table with the same headers as the other tables. 76 | const headerValues = workbook.getWorksheet(sheetNames[0]).getTables()[0].getHeaderRowRange().getTexts(); 77 | const targetRange = newSheet.getRange('A1').getResizedRange(headerValues.length-1, headerValues[0].length-1); 78 | targetRange.setValues(headerValues); 79 | const combinedTable = newSheet.addTable(targetRange.getAddress(), true); 80 | 81 | // Go through each listed worksheet and get their tables. 82 | sheetNames.forEach((sheet) => { 83 | const tables = workbook.getWorksheet(sheet).getTables(); 84 | for (let table of tables) { 85 | // Get the rows from the tables. 86 | let dataValues = table.getRangeBetweenHeaderAndTotal().getTexts(); 87 | let rowCount = table.getRowCount(); 88 | 89 | // If there's data in the table, add it to the combined table. 90 | if (rowCount > 0) { 91 | combinedTable.addRows(-1, dataValues); 92 | } 93 | } 94 | }); 95 | } 96 | ``` 97 | 98 | ## Training video: Combine data from multiple Excel tables into a single table 99 | 100 | [Watch Sudhi Ramamurthy walk through this sample on YouTube](https://youtu.be/di-8JukK3Lc). 101 | -------------------------------------------------------------------------------- /docs/resources/samples/count-blank-rows.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Count blank rows on sheets 3 | description: Learn how to use Office Scripts to detect if there are any blank rows instead of data in worksheets and then report the blank row count to be used in a Power Automate flow. 4 | ms.date: 06/29/2021 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Count blank rows on sheets 9 | 10 | This project includes two scripts: 11 | 12 | * [Count blank rows on a given sheet](#sample-code-count-blank-rows-on-a-given-sheet): Traverses the used range on a given worksheet and returns a blank row count. 13 | * [Count blank rows on all sheets](#sample-code-count-blank-rows-on-all-sheets): Traverses the used range on _all of the worksheets_ and returns a blank row count. 14 | 15 | > [!NOTE] 16 | > For your script, a blank row is any row where there's no data. The row can have formatting. 17 | 18 | _This sheet returns count of 4 blank rows_ 19 | 20 | :::image type="content" source="../../images/blank-rows.png" alt-text="A worksheet showing data with blank rows."::: 21 | 22 | _This sheet returns count of 0 blank rows (all rows have some data)_ 23 | 24 | :::image type="content" source="../../images/no-blank-rows.png" alt-text="A worksheet showing data without blank rows."::: 25 | 26 | ## Sample code: Count blank rows on a given sheet 27 | 28 | ```TypeScript 29 | function main(workbook: ExcelScript.Workbook): number 30 | { 31 | // Get the worksheet named "Sheet1". 32 | const sheet = workbook.getWorksheet('Sheet1'); 33 | 34 | // Get the entire data range. 35 | const range = sheet.getUsedRange(true); 36 | 37 | // If the used range is empty, end the script. 38 | if (!range) { 39 | console.log(`No data on this sheet.`); 40 | return; 41 | } 42 | 43 | // Log the address of the used range. 44 | console.log(`Used range for the worksheet: ${range.getAddress()}`); 45 | 46 | // Look through the values in the range for blank rows. 47 | const values = range.getValues(); 48 | let emptyRows = 0; 49 | for (let row of values) { 50 | let emptyRow = true; 51 | 52 | // Look at every cell in the row for one with a value. 53 | for (let cell of row) { 54 | if (cell.toString().length > 0) { 55 | emptyRow = false 56 | } 57 | } 58 | 59 | // If no cell had a value, the row is empty. 60 | if (emptyRow) { 61 | emptyRows++; 62 | } 63 | } 64 | 65 | // Log the number of empty rows. 66 | console.log(`Total empty rows: ${emptyRows}`); 67 | 68 | // Return the number of empty rows for use in a Power Automate flow. 69 | return emptyRows; 70 | } 71 | ``` 72 | 73 | ## Sample code: Count blank rows on all sheets 74 | 75 | ```TypeScript 76 | function main(workbook: ExcelScript.Workbook): number 77 | { 78 | // Loop through every worksheet in the workbook. 79 | const sheets = workbook.getWorksheets(); 80 | let emptyRows = 0; 81 | for (let sheet of sheets) { 82 | // Get the entire data range. 83 | const range = sheet.getUsedRange(true); 84 | 85 | // If the used range is empty, skip to the next worksheet. 86 | if (!range) { 87 | console.log(`No data on this sheet.`); 88 | continue; 89 | } 90 | 91 | // Log the address of the used range. 92 | console.log(`Used range for the worksheet: ${range.getAddress()}`); 93 | 94 | // Look through the values in the range for blank rows. 95 | const values = range.getValues(); 96 | for (let row of values) { 97 | let emptyRow = true; 98 | 99 | // Look at every cell in the row for one with a value. 100 | for (let cell of row) { 101 | if (cell.toString().length > 0) { 102 | emptyRow = false 103 | } 104 | } 105 | 106 | // If no cell had a value, the row is empty. 107 | if (emptyRow) { 108 | emptyRows++; 109 | } 110 | } 111 | } 112 | 113 | // Log the number of empty rows. 114 | console.log(`Total empty rows: ${emptyRows}`); 115 | 116 | // Return the number of empty rows for use in a Power Automate flow. 117 | return emptyRows; 118 | } 119 | ``` 120 | -------------------------------------------------------------------------------- /docs/resources/samples/daily-readings.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/daily-readings.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/data-validation-samples.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Data validation: dropdown lists, prompts, and warning pop-ups" 3 | description: Learn how to add data validation to a cell and give the user a selection of values to enter. 4 | ms.date: 09/20/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Data validation: dropdown lists, prompts, and warning pop-ups 9 | 10 | Data validation helps the user ensure consistency in a worksheet. Use these features to limit what can be entered into a cell and provide warnings or errors to users when those conditions aren't met. To learn more about data validation in Excel, see [Apply data validation to cells](https://support.microsoft.com/office/29fecbcc-d1b9-42c1-9d76-eff3ce5f7249). 11 | 12 | ## Create a dropdown list using data validation 13 | 14 | The following sample creates a dropdown selection list for a cell. It uses the existing values of the selected range as the choices for the list. 15 | 16 | :::image type="content" source="../../images/sample-data-validation.png" alt-text="A worksheet showing a range of three cells containing color choices 'red, blue, green' and next to it, the same choices shown in a dropdown list."::: 17 | 18 | ```TypeScript 19 | function main(workbook: ExcelScript.Workbook) { 20 | // Get the values for data validation. 21 | const selectedRange = workbook.getSelectedRange(); 22 | const rangeValues = selectedRange.getValues(); 23 | 24 | // Convert the values into a comma-delimited string. 25 | let dataValidationListString = ""; 26 | rangeValues.forEach((rangeValueRow) => { 27 | rangeValueRow.forEach((value) => { 28 | dataValidationListString += value + ","; 29 | }); 30 | }); 31 | 32 | // Clear the old range. 33 | selectedRange.clear(ExcelScript.ClearApplyTo.contents); 34 | 35 | // Apply the data validation to the first cell in the selected range. 36 | const targetCell = selectedRange.getCell(0,0); 37 | const dataValidation = targetCell.getDataValidation(); 38 | 39 | // Set the content of the dropdown list. 40 | dataValidation.setRule({ 41 | list: { 42 | inCellDropDown: true, 43 | source: dataValidationListString 44 | } 45 | }); 46 | } 47 | ``` 48 | 49 | ## Add a prompt to a range 50 | 51 | This example creates a prompt note that appears when a user enters the given cells. This is used to remind users about input requirements, without strict enforcement. 52 | 53 | :::image type="content" source="../../images/data-validation-prompt.png" alt-text="A prompt with the title 'First names only' and the message 'Only enter the first name of the employee, not the full name.' next to a worksheet with some names in cells."::: 54 | 55 | ```TypeScript 56 | /** 57 | * This script creates a text prompt that's shown in C2:C8 when a user enters the cell. 58 | */ 59 | function main(workbook: ExcelScript.Workbook) { 60 | // Get the data validation object for C2:C8 in the current worksheet. 61 | const selectedSheet = workbook.getActiveWorksheet(); 62 | const dataValidation = selectedSheet.getRange("C2:C8").getDataValidation(); 63 | 64 | // Clear any previous validation to avoid conflicts. 65 | dataValidation.clear(); 66 | 67 | // Create a prompt to remind users to only enter first names in this column. 68 | const prompt: ExcelScript.DataValidationPrompt = { 69 | showPrompt: true, 70 | title: "First names only", 71 | message: "Only enter the first name of the employee, not the full name." 72 | } 73 | dataValidation.setPrompt(prompt); 74 | } 75 | ``` 76 | 77 | ## Alert the user when invalid data is entered 78 | 79 | The following sample script prevents the user from entering anything other than positive numbers into a range. If they try to put anything else, an error message pops up and indicates the problem. 80 | 81 | :::image type="content" source="../../images/data-validation-error.png" alt-text="An error message with the title 'Invalid data' and the message 'Positive numbers only.' next to a cell with a negative number."::: 82 | 83 | ```TypeScript 84 | /** 85 | * This script creates a data validation rule for the range B2:B5. 86 | * All values in that range must be a positive number. 87 | * Attempts to enter other values are blocked and an error message appears. 88 | */ 89 | function main(workbook: ExcelScript.Workbook) { 90 | // Get the range B2:B5 in the active worksheet. 91 | const currentSheet = workbook.getActiveWorksheet(); 92 | const positiveNumberOnlyCells = currentSheet.getRange("B2:B5"); 93 | 94 | // Create a data validation rule to only allow positive numbers. 95 | const positiveNumberValidation: ExcelScript.BasicDataValidation = { 96 | formula1: "0", 97 | operator: ExcelScript.DataValidationOperator.greaterThan 98 | }; 99 | const positiveNumberOnlyRule: ExcelScript.DataValidationRule = { 100 | wholeNumber: positiveNumberValidation 101 | }; 102 | 103 | // Set the rule on the range. 104 | const rangeDataValidation = positiveNumberOnlyCells.getDataValidation(); 105 | rangeDataValidation.setRule(positiveNumberOnlyRule); 106 | 107 | // Create an alert to appear when data other than positive numbers are entered. 108 | const positiveNumberOnlyAlert: ExcelScript.DataValidationErrorAlert = { 109 | message: "Positive numbers only.", 110 | showAlert: true, 111 | style: ExcelScript.DataValidationAlertStyle.stop, 112 | title: "Invalid data" 113 | }; 114 | rangeDataValidation.setErrorAlert(positiveNumberOnlyAlert); 115 | } 116 | ``` 117 | -------------------------------------------------------------------------------- /docs/resources/samples/email-chart-table.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/email-chart-table.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/email-images-chart-table.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Email the images of an Excel chart and table 3 | description: Learn how to use Office Scripts and Power Automate to extract and email the images of an Excel chart and table. 4 | ms.date: 05/21/2024 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Use Office Scripts and Power Automate to email images of a chart and table 9 | 10 | This sample uses Office Scripts and Power Automate to create a chart. It then emails images of the chart and its base table. 11 | 12 | ## Example scenario 13 | 14 | * Calculate to get latest results. 15 | * Create chart. 16 | * Get chart and table images. 17 | * Email the images with Power Automate. 18 | 19 | ### Input data 20 | 21 | :::image type="content" source="../../images/input-data.png" alt-text="A worksheet showing a table of input data."::: 22 | 23 | ### Output chart 24 | 25 | :::image type="content" source="../../images/chart-created.png" alt-text="The column chart created showing amount due by customer."::: 26 | 27 | ### Email that was received through Power Automate flow 28 | 29 | :::image type="content" source="../../images/email-received.png" alt-text="The email sent by the flow showing the Excel chart embedded in the body."::: 30 | 31 | ## Solution 32 | 33 | This solution has two parts: 34 | 35 | 1. [An Office Script to calculate and extract Excel chart and table](#sample-code-calculate-and-extract-excel-chart-and-table) 36 | 1. A Power Automate flow to invoke the script and email the results. For an example on how to do this, see [Create an automated workflow with Power Automate](../../tutorials/excel-power-automate-returns.md#create-an-automated-workflow-with-power-automate). 37 | 38 | ## Setup: Sample Excel file 39 | 40 | This workbook contains the data, objects, and formatting expected by the script. 41 | 42 | > [!div class="nextstepaction"] 43 | > [Download the sample workbook](email-chart-table.xlsx) 44 | 45 | ## Sample code: Calculate and extract Excel chart and table 46 | 47 | Add the following script to the sample workbook. In Excel, use **Automate** > **New Script** to paste the code and save the script. Save it as **Get chart image** and try the sample yourself! 48 | 49 | ```TypeScript 50 | function main(workbook: ExcelScript.Workbook): ReportImages { 51 | // Recalculate the workbook to ensure all tables and charts are updated. 52 | workbook.getApplication().calculate(ExcelScript.CalculationType.full); 53 | 54 | // Get the data from the "InvoiceAmounts" table. 55 | const sheet1 = workbook.getWorksheet("Sheet1"); 56 | const table = workbook.getWorksheet('InvoiceAmounts').getTables()[0]; 57 | const rows = table.getRange().getTexts(); 58 | 59 | // Get only the "Customer Name" and "Amount due" columns, then remove the "Total" row. 60 | const selectColumns = rows.map((row) => { 61 | return [row[2], row[5]]; 62 | }); 63 | table.setShowTotals(true); 64 | selectColumns.splice(selectColumns.length - 1, 1); 65 | console.log(selectColumns); 66 | 67 | // Delete the "ChartSheet" worksheet if it's present, then recreate it. 68 | workbook.getWorksheet('ChartSheet')?.delete(); 69 | const chartSheet = workbook.addWorksheet('ChartSheet'); 70 | 71 | // Add the selected data to the new worksheet. 72 | const targetRange = chartSheet.getRange('A1').getResizedRange(selectColumns.length - 1, selectColumns[0].length - 1); 73 | targetRange.setValues(selectColumns); 74 | 75 | // Insert the chart on sheet 'ChartSheet' at cell "D1". 76 | const chart = chartSheet.addChart(ExcelScript.ChartType.columnClustered, targetRange); 77 | chart.setPosition('D1'); 78 | 79 | // Get images of the chart and table, then return them for a Power Automate flow. 80 | const chartImage = chart.getImage(); 81 | const tableImage = table.getRange().getImage(); 82 | return { chartImage, tableImage }; 83 | } 84 | 85 | // The interface for table and chart images. 86 | interface ReportImages { 87 | chartImage: string 88 | tableImage: string 89 | } 90 | ``` 91 | 92 | ## Power Automate flow: Email the chart and table images 93 | 94 | This flow runs the script and emails the returned images. 95 | 96 | 1. Create a new **Instant cloud flow**. 97 | 98 | 1. Choose **Manually trigger a flow** and select **Create**. 99 | 100 | 1. Add a **New step** that uses the **Excel Online (Business)** connector with the **Run script** action. Use the following values for the action. 101 | * **Location**: OneDrive for Business 102 | * **Document Library**: OneDrive 103 | * **File**: email-chart-table.xlsx ([selected with the file chooser](../../testing/power-automate-troubleshooting.md#select-workbooks-with-the-file-browser-control)) 104 | * **Script**: Get chart image 105 | 106 | :::image type="content" source="../../images/email-chart-sample-flow-1.png" alt-text="The completed Excel Online (Business) connector in Power Automate."::: 107 | 108 | 1. This sample uses Outlook as the email client. You could use any email connector Power Automate supports, but the rest of the steps assume that you chose Outlook. Add a **New step** that uses the **Office 365 Outlook** connector and the **Send and email (V2)** action. Use the following values for the action. 109 | * **To**: Your test email account (or personal email) 110 | * **Subject**: Please Review Report Data 111 | * For the **Body** field, select "Code View" (`<>`) and enter the following: 112 | 113 | ```HTML 114 |

Please review the following report data:
115 |
116 | Chart:
117 |
118 | 119 |
120 | Data:
121 |
122 | 123 |
124 |

125 | ``` 126 | 127 | :::image type="content" source="../../images/email-chart-sample-flow-2.png" alt-text="The completed Office 365 Outlook connector in Power Automate."::: 128 | 129 | 1. Save the flow and try it out. Use the **Test** button on the flow editor page or run the flow through your **My flows** tab. Be sure to allow access when prompted. 130 | 131 | ## Training video: Extract and email images of chart and table 132 | 133 | [Watch Sudhi Ramamurthy walk through this sample on YouTube](https://youtu.be/152GJyqc-Kw). 134 | -------------------------------------------------------------------------------- /docs/resources/samples/event-data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/event-data.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/excel-calculation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Manage calculation mode in Excel 3 | description: Learn how to use Office Scripts to manage the calculation mode in Excel. 4 | ms.date: 05/06/2021 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Manage calculation mode in Excel 9 | 10 | This sample shows how to use the [calculation mode](/javascript/api/office-scripts/excelscript/excelscript.calculationmode) and calculate methods in Excel using Office Scripts. You can try the script on any Excel file. 11 | 12 | ## Scenario 13 | 14 | Workbooks with large numbers of formulas can take a while to recalculate. Rather than letting Excel control when calculations happen, you can manage them as part of your script. This will help with performance in certain scenarios. 15 | 16 | The sample script sets the calculation mode to manual. This means that the workbook will only recalculate formulas when the script tells it to (or you [manually calculate through the UI](https://support.microsoft.com/office/73fc7dac-91cf-4d36-86e8-67124f6bcce4)). The script then displays the current calculation mode and fully recalculates the entire workbook. 17 | 18 | ## Sample code: Control calculation mode 19 | 20 | ```TypeScript 21 | function main(workbook: ExcelScript.Workbook) { 22 | // Set the calculation mode to manual. 23 | workbook.getApplication().setCalculationMode(ExcelScript.CalculationMode.manual); 24 | // Get and log the calculation mode. 25 | const calcMode = workbook.getApplication().getCalculationMode(); 26 | console.log(calcMode); 27 | // Manually calculate the file. 28 | workbook.getApplication().calculate(ExcelScript.CalculationType.full); 29 | } 30 | ``` 31 | 32 | ## Training video: Manage calculation mode 33 | 34 | [Watch Sudhi Ramamurthy walk through this sample on YouTube](https://youtu.be/iw6O8QH01CI). 35 | -------------------------------------------------------------------------------- /docs/resources/samples/external-fetch-calls.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Use external fetch calls in Office Scripts 3 | description: Learn how to make external API calls in Office Scripts. 4 | ms.date: 06/10/2022 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Use external fetch calls in Office Scripts 9 | 10 | This script gets basic information about a user's GitHub repositories. It shows how to use `fetch` in a simple scenario. For more information about using `fetch` or other external calls, read [External API call support in Office Scripts](../../develop/external-calls.md). For information about working with [JSON](https://www.w3schools.com/whatis/whatis_json.asp) objects, like what is returned by the GitHub APIs, read [Use JSON to pass data to and from Office Scripts](../../develop/use-json.md). 11 | 12 | Learn more about the GitHub APIs being used in the [GitHub API reference](https://docs.github.com/rest/reference/repos#list-repositories-for-a-user). You can also see the raw API call output by visiting `https://api.github.com/users/{USERNAME}/repos` in a web browser (be sure to replace the {USERNAME} placeholder with your GitHub ID). 13 | 14 | ![Get repositories info example](../../images/git.png) 15 | 16 | ## Sample code: Get basic information about user's GitHub repositories 17 | 18 | ```TypeScript 19 | async function main(workbook: ExcelScript.Workbook) { 20 | // Call the GitHub REST API. 21 | // Replace the {USERNAME} placeholder with your GitHub username. 22 | const response = await fetch('https://api.github.com/users/{USERNAME}/repos'); 23 | const repos: Repository[] = await response.json(); 24 | 25 | // Create an array to hold the returned values. 26 | const rows: (string | boolean | number)[][] = []; 27 | 28 | // Convert each repository block into a row. 29 | for (let repo of repos) { 30 | rows.push([repo.id, repo.name, repo.license?.name, repo.license?.url]); 31 | } 32 | // Create a header row. 33 | const sheet = workbook.getActiveWorksheet(); 34 | sheet.getRange('A1:D1').setValues([["ID", "Name", "License Name", "License URL"]]); 35 | 36 | // Add the data to the current worksheet, starting at "A2". 37 | const range = sheet.getRange('A2').getResizedRange(rows.length - 1, rows[0].length - 1); 38 | range.setValues(rows); 39 | } 40 | 41 | // An interface matching the returned JSON for a GitHub repository. 42 | interface Repository { 43 | name: string, 44 | id: string, 45 | license?: License 46 | } 47 | 48 | // An interface matching the returned JSON for a GitHub repo license. 49 | interface License { 50 | name: string, 51 | url: string 52 | } 53 | ``` 54 | 55 | ## Training video: How to make external API calls 56 | 57 | [Watch Sudhi Ramamurthy walk through this sample on YouTube](https://youtu.be/fulP29J418E). 58 | -------------------------------------------------------------------------------- /docs/resources/samples/happy-tree.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/happy-tree.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/highlight-alert-excel-files.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/highlight-alert-excel-files.zip -------------------------------------------------------------------------------- /docs/resources/samples/input-table-filters.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/input-table-filters.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/javascript-dates.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: JavaScript Date samples 3 | description: A collection of samples on how to use JavaScript Date objects with Excel. 4 | ms.date: 09/08/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # JavaScript `Date` samples 9 | 10 | These samples show how to use the JavaScript [Date](https://developer.mozilla.org/docs/web/javascript/reference/global_objects/date) object. 11 | 12 | ## Write the current date and time 13 | 14 | The following sample gets the current date and time and then writes those values to two cells in the active worksheet. 15 | 16 | ```TypeScript 17 | function main(workbook: ExcelScript.Workbook) { 18 | // Get the cells at A1 and B1. 19 | let dateRange = workbook.getActiveWorksheet().getRange("A1"); 20 | let timeRange = workbook.getActiveWorksheet().getRange("B1"); 21 | 22 | // Get the current date and time with the JavaScript Date object. 23 | let date = new Date(Date.now()); 24 | 25 | // Add the date string to A1. 26 | dateRange.setValue(date.toLocaleDateString()); 27 | 28 | // Add the time string to B1. 29 | timeRange.setValue(date.toLocaleTimeString()); 30 | } 31 | ``` 32 | 33 | ## Read an Excel date 34 | 35 | This sample reads a date that's stored in Excel and translates it to a JavaScript `Date` object. It uses the date's numeric serial number as input for the JavaScript `Date`. This serial number is described in the [NOW() function](https://support.microsoft.com/office/3337fd29-145a-4347-b2e6-20c904739c46) article. 36 | 37 | ```TypeScript 38 | function main(workbook: ExcelScript.Workbook) { 39 | // Read a date at cell A1 from Excel. 40 | let dateRange = workbook.getActiveWorksheet().getRange("A1"); 41 | 42 | // Convert the Excel date to a JavaScript Date object. 43 | let excelDateValue = dateRange.getValue() as number; 44 | let javaScriptDate = new Date(Math.round((excelDateValue - 25569) * 86400 * 1000)); 45 | console.log(javaScriptDate); 46 | } 47 | ``` 48 | 49 | ## See also 50 | 51 | - [Use built-in JavaScript objects in Office Scripts](../../develop/javascript-objects.md) 52 | -------------------------------------------------------------------------------- /docs/resources/samples/move-rows-across-tables.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Move rows across tables using Office Scripts 3 | description: Learn how to move rows across tables by saving filters, then processing and reapplying the filters. 4 | ms.date: 06/29/2021 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Move rows across tables 9 | 10 | This script does the following: 11 | 12 | * Selects rows from the source table where the value in a column is equal to some value (`FILTER_VALUE` in the script). 13 | * Moves all selected rows into the target table in another worksheet. 14 | * Reapplies the relevant filters to the source table. 15 | 16 | ## Setup: Sample Excel file 17 | 18 | This workbook contains the data, objects, and formatting expected by the script. 19 | 20 | > [!div class="nextstepaction"] 21 | > [Download the sample workbook](input-table-filters.xlsx) 22 | 23 | ## Sample code: Move rows using range values 24 | 25 | Add the following script to the sample workbook and try the sample yourself! 26 | 27 | ```TypeScript 28 | function main(workbook: ExcelScript.Workbook) { 29 | 30 | // You can change these names to match the data in your workbook. 31 | const TARGET_TABLE_NAME = 'Table1'; 32 | const SOURCE_TABLE_NAME = 'Table2'; 33 | 34 | // Select what will be moved between tables. 35 | const FILTER_COLUMN_INDEX = 1; 36 | const FILTER_VALUE = 'Clothing'; 37 | 38 | // Get the Table objects. 39 | let targetTable = workbook.getTable(TARGET_TABLE_NAME); 40 | let sourceTable = workbook.getTable(SOURCE_TABLE_NAME); 41 | 42 | // If either table is missing, report that information and stop the script. 43 | if (!targetTable || !sourceTable) { 44 | console.log(`Tables missing - Check to make sure both source (${TARGET_TABLE_NAME}) and target table (${SOURCE_TABLE_NAME}) are present before running the script. `); 45 | return; 46 | } 47 | 48 | // Save the filter criteria currently on the source table. 49 | const originalTableFilters = {}; 50 | // For each table column, collect the filter criteria on that column. 51 | sourceTable.getColumns().forEach((column) => { 52 | let originalColumnFilter = column.getFilter().getCriteria(); 53 | if (originalColumnFilter) { 54 | originalTableFilters[column.getName()] = originalColumnFilter; 55 | } 56 | }); 57 | 58 | // Get all the data from the table. 59 | const sourceRange = sourceTable.getRangeBetweenHeaderAndTotal(); 60 | const dataRows: (number | string | boolean)[][] = sourceTable.getRangeBetweenHeaderAndTotal().getValues(); 61 | 62 | // Create variables to hold the rows to be moved and their addresses. 63 | let rowsToMoveValues: (number | string | boolean)[][] = []; 64 | let rowAddressToRemove: string[] = []; 65 | 66 | // Get the data values from the source table. 67 | for (let i = 0; i < dataRows.length; i++) { 68 | if (dataRows[i][FILTER_COLUMN_INDEX] === FILTER_VALUE) { 69 | rowsToMoveValues.push(dataRows[i]); 70 | 71 | // Get the intersection between table address and the entire row where we found the match. This provides the address of the range to remove. 72 | let address = sourceRange.getIntersection(sourceRange.getCell(i,0).getEntireRow()).getAddress(); 73 | rowAddressToRemove.push(address); 74 | } 75 | } 76 | 77 | // If there are no data rows to process, end the script. 78 | if (rowsToMoveValues.length < 1) { 79 | console.log('No rows selected from the source table match the filter criteria.'); 80 | return; 81 | } 82 | 83 | console.log(`Adding ${rowsToMoveValues.length} rows to target table.`); 84 | 85 | // Insert rows at the end of target table. 86 | targetTable.addRows(-1, rowsToMoveValues) 87 | 88 | // Remove the rows from the source table. 89 | const sheet = sourceTable.getWorksheet(); 90 | 91 | // Remove all filters before removing rows. 92 | sourceTable.getAutoFilter().clearCriteria(); 93 | 94 | // Important: Remove the rows starting at the bottom of the table. 95 | // Otherwise, the lower rows change position before they are deleted. 96 | console.log(`Removing ${rowAddressToRemove.length} rows from the source table.`); 97 | rowAddressToRemove.reverse().forEach((address) => { 98 | sheet.getRange(address).delete(ExcelScript.DeleteShiftDirection.up); 99 | }); 100 | 101 | // Reapply the original filters. 102 | Object.keys(originalTableFilters).forEach((columnName) => { 103 | sourceTable.getColumnByName(columnName).getFilter().apply(originalTableFilters[columnName]); 104 | }); 105 | } 106 | ``` 107 | 108 | ## Training video: Move rows across tables 109 | 110 | [Watch Sudhi Ramamurthy walk through this sample on YouTube](https://youtu.be/_3t3Pk4i2L0). There are two scripts shown in the video's solution. The main difference is how the rows are selected. 111 | 112 | * In the first variant, the rows are selected by applying the table filter and reading the visible range. 113 | * In the second, the rows are selected by reading the values and extracting the row values (which is what the sample on this page uses). 114 | -------------------------------------------------------------------------------- /docs/resources/samples/remove-hyperlinks-from-cells.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Remove hyperlinks from each cell in an Excel worksheet 3 | description: Learn how to use Office Scripts to remove hyperlinks from each cell in an Excel worksheet. 4 | ms.date: 06/29/2021 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Remove hyperlinks from each cell in an Excel worksheet 9 | 10 | This sample clears all of the hyperlinks from the current worksheet. It traverses the worksheet and if there is any hyperlink associated with the cell, it clears the hyperlink yet retains the cell value as is. Also logs the time it takes to complete traversal. 11 | 12 | > [!NOTE] 13 | > This only works if the cell count is < 10k. 14 | 15 | ## Setup: Sample Excel file 16 | 17 | This workbook contains the data, objects, and formatting expected by the script. 18 | 19 | > [!div class="nextstepaction"] 20 | > [Download the sample workbook](remove-hyperlinks.xlsx) 21 | 22 | ## Sample code: Remove hyperlinks 23 | 24 | Add the following script to the sample workbook and try the sample yourself! 25 | 26 | ```TypeScript 27 | function main(workbook: ExcelScript.Workbook, sheetName: string = 'Sheet1') { 28 | // Get the active worksheet. 29 | let sheet = workbook.getWorksheet(sheetName); 30 | 31 | // Get the used range to operate on. 32 | // For large ranges (over 10000 entries), consider splitting the operation into batches for performance. 33 | const targetRange = sheet.getUsedRange(true); 34 | console.log(`Target Range to clear hyperlinks from: ${targetRange.getAddress()}`); 35 | 36 | const rowCount = targetRange.getRowCount(); 37 | const colCount = targetRange.getColumnCount(); 38 | console.log(`Searching for hyperlinks in ${targetRange.getAddress()} which contains ${(rowCount * colCount)} cells`); 39 | 40 | // Go through each individual cell looking for a hyperlink. 41 | // This allows us to limit the formatting changes to only the cells with hyperlink formatting. 42 | let clearedCount = 0; 43 | for (let i = 0; i < rowCount; i++) { 44 | for (let j = 0; j < colCount; j++) { 45 | const cell = targetRange.getCell(i, j); 46 | const hyperlink = cell.getHyperlink(); 47 | if (hyperlink) { 48 | cell.clear(ExcelScript.ClearApplyTo.hyperlinks); 49 | cell.getFormat().getFont().setUnderline(ExcelScript.RangeUnderlineStyle.none); 50 | cell.getFormat().getFont().setColor('Black'); 51 | clearedCount++; 52 | } 53 | } 54 | } 55 | 56 | console.log(`Done. Cleared hyperlinks from ${clearedCount} cells`); 57 | } 58 | ``` 59 | 60 | ## Training video: Remove hyperlinks from each cell in an Excel worksheet 61 | 62 | [Watch Sudhi Ramamurthy walk through this sample on YouTube](https://youtu.be/v20fdinxpHU). 63 | -------------------------------------------------------------------------------- /docs/resources/samples/remove-hyperlinks.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/remove-hyperlinks.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/report-day-to-day-changes.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Record day-to-day changes in Excel and report them with a Power Automate flow 3 | description: Learn how to use Office Scripts and Power Automate to track value changes in a workbook 4 | ms.date: 11/29/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Record day-to-day changes in Excel and report them with a Power Automate flow 9 | 10 | Power Automate and Office Scripts combine to handle repetitive tasks for you. In this sample, you're tasked with recording a single numerical reading in a workbook every day and reporting the change since yesterday. You'll build a flow to get that reading, log it in the workbook, and report the change through an email. 11 | 12 | ## Setup: Sample Excel file 13 | 14 | This workbook contains the data, objects, and formatting expected by the script. 15 | 16 | > [!div class="nextstepaction"] 17 | > [Download the sample workbook](daily-readings.xlsx) 18 | 19 | ## Sample code: Record and report daily readings 20 | 21 | Add the following script to the sample workbook. In Excel, use **Automate** > **New Script** to paste the code and save the script. Save it as **Record daily value** and try the sample yourself! 22 | 23 | ```TypeScript 24 | function main(workbook: ExcelScript.Workbook, newData: string): string { 25 | // Get the table by its name. 26 | const table = workbook.getTable("ReadingTable"); 27 | 28 | // Read the current last entry in the Reading column. 29 | const readingColumn = table.getColumnByName("Reading"); 30 | const readingColumnValues = readingColumn.getRange().getValues(); 31 | const previousValue = readingColumnValues[readingColumnValues.length - 1][0] as number; 32 | 33 | // Add a row with the date, new value, and a formula calculating the difference. 34 | const currentDate = new Date(Date.now()).toLocaleDateString(); 35 | const newRow = [currentDate, newData, "=[@Reading]-OFFSET([@Reading],-1,0)"]; 36 | table.addRow(-1, newRow); 37 | 38 | // Return the difference between the newData and the previous entry. 39 | const difference = Number.parseFloat(newData) - previousValue; 40 | console.log(difference); 41 | return difference.toString(); 42 | } 43 | ``` 44 | 45 | ## Sample flow: Report day-to-day changes 46 | 47 | Follow these steps to build a [Power Automate](https://powerautomate.microsoft.com/) flow for the sample. 48 | 49 | 1. Create a new **Scheduled cloud flow**. 50 | 1. Schedule the flow to repeat every **1 Day**. 51 | 52 | :::image type="content" source="../../images/day-to-day-changes-flow-1.png" alt-text="The flow creation step showing it will repeat every day."::: 53 | 54 | 1. Select **Create**. 55 | 1. In a real flow, you'll add a step that gets your data. The data can come from another workbook, a Teams adaptive card, or any other source. To test the sample, make a test number. Add an action and choose the **Initialize variable** action. Give it the following values. 56 | 1. **Name**: Input 57 | 1. **Type**: Integer 58 | 1. **Value**: 190000 59 | 60 | :::image type="content" source="../../images/day-to-day-changes-flow-2.png" alt-text="The Initialize variable action with the given values."::: 61 | 62 | 1. Add an action and choose the **Excel Online (Business)** connector's **Run script** action. Use the following values for the action. 63 | 1. **Location**: OneDrive for Business 64 | 1. **Document Library**: OneDrive 65 | 1. **File**: daily-readings.xlsx *(Chosen through the file browser)* 66 | 1. **Script**: Record daily value 67 | 1. **newData**: Input *(dynamic content)* 68 | 69 | :::image type="content" source="../../images/day-to-day-changes-flow-3.png" alt-text="The Run script action with the given values."::: 70 | 71 | 1. The script returns the daily reading difference as dynamic content named "result". For the sample, you can email the information to yourself. Add an action and choose the **Outlook** connector's **Send an email (V2)** action (or whatever email client you prefer). Use the following values to complete the action. 72 | 1. **To**: Your email address 73 | 1. **Subject**: Daily reading change 74 | 1. **Body**: "Difference from yesterday:" result *(dynamic content from Excel)* 75 | 76 | :::image type="content" source="../../images/day-to-day-changes-flow-4.png" alt-text="The completed Outlook connector in Power Automate."::: 77 | 78 | 1. Save the flow and try it out. Use the **Test** button on the flow editor page. Be sure to allow access when prompted. 79 | -------------------------------------------------------------------------------- /docs/resources/samples/row-and-column-visibility.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Row and column visibility samples 3 | description: A collection of samples that show the basics of visibility in Excel. 4 | ms.date: 09/08/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Row and column visibility samples 9 | 10 | These samples demonstrate how to show, hide, and freeze rows and columns. 11 | 12 | ## Hide columns 13 | 14 | This script hides columns "D", "F", and "J". 15 | 16 | ```TypeScript 17 | function main(workbook: ExcelScript.Workbook) { 18 | // Get the current worksheet. 19 | const sheet = workbook.getActiveWorksheet(); 20 | 21 | // Hide columns D, F, and J. 22 | sheet.getRange("D:D").setColumnHidden(true); 23 | sheet.getRange("F:F").setColumnHidden(true); 24 | sheet.getRange("J:J").setColumnHidden(true); 25 | } 26 | ``` 27 | 28 | ## Show all rows and columns 29 | 30 | This script gets the worksheet's used range, checks if there are any hidden rows and columns, and shows them. 31 | 32 | ```TypeScript 33 | function main(workbook: ExcelScript.Workbook) { 34 | // Get the currently selected sheet. 35 | const selectedSheet = workbook.getActiveWorksheet(); 36 | 37 | // Get the entire data range. 38 | const range = selectedSheet.getUsedRange(); 39 | 40 | // If the used range is empty, end the script. 41 | if (!range) { 42 | console.log(`No data on this sheet.`) 43 | return; 44 | } 45 | 46 | // If no columns are hidden, log message, else show columns. 47 | if (range.getColumnHidden() == false) { 48 | console.log(`No columns hidden`); 49 | } else { 50 | range.setColumnHidden(false); 51 | } 52 | 53 | // If no rows are hidden, log message, else, show rows. 54 | if (range.getRowHidden() == false) { 55 | console.log(`No rows hidden`); 56 | } else { 57 | range.setRowHidden(false); 58 | } 59 | } 60 | ``` 61 | 62 | ## Freeze currently selected cells 63 | 64 | This script checks what cells are currently selected and freezes that selection, so those cells are always visible. 65 | 66 | ```TypeScript 67 | function main(workbook: ExcelScript.Workbook) { 68 | // Get the currently selected sheet. 69 | const selectedSheet = workbook.getActiveWorksheet(); 70 | 71 | // Get the current selected range. 72 | const selectedRange = workbook.getSelectedRange(); 73 | 74 | // If no cells are selected, end the script. 75 | if (!selectedRange) { 76 | console.log(`No cells in the worksheet are selected.`); 77 | return; 78 | } 79 | 80 | // Log the address of the selected range 81 | console.log(`Selected range for the worksheet: ${selectedRange.getAddress()}`); 82 | 83 | // Freeze the selected range. 84 | selectedSheet.getFreezePanes().freezeAt(selectedRange); 85 | } 86 | ``` 87 | -------------------------------------------------------------------------------- /docs/resources/samples/speaker-registrations.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/speaker-registrations.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/table-data-with-hyperlinks.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/table-data-with-hyperlinks.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/table-of-contents.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Create a workbook table of contents 3 | description: Learn how to create a table of contents with links to each worksheet. 4 | ms.date: 08/08/2023 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Create a workbook table of contents 9 | 10 | This sample shows how to create a table of contents for the workbook. Each entry in the table of contents is a hyperlink to one of the worksheets in the workbook. 11 | 12 | :::image type="content" source="../../images/table-of-contents-sample.png" alt-text="The table of contents worksheet showing links to the other worksheets."::: 13 | 14 | ## Setup: Sample Excel file 15 | 16 | This workbook contains the data, objects, and formatting expected by the script. 17 | 18 | > [!div class="nextstepaction"] 19 | > [Download the sample workbook](table-of-contents.xlsx) 20 | 21 | ## Sample code: Create a workbook table of contents 22 | 23 | Add the following script to the sample workbook and try the sample yourself! 24 | 25 | ```TypeScript 26 | function main(workbook: ExcelScript.Workbook) { 27 | // Insert a new worksheet at the beginning of the workbook. 28 | let tocSheet = workbook.addWorksheet(); 29 | tocSheet.setPosition(0); 30 | tocSheet.setName("Table of Contents"); 31 | 32 | // Give the worksheet a title in the sheet. 33 | tocSheet.getRange("A1").setValue("Table of Contents"); 34 | tocSheet.getRange("A1").getFormat().getFont().setBold(true); 35 | 36 | // Create the table of contents headers. 37 | let tocRange = tocSheet.getRange("A2:B2") 38 | tocRange.setValues([["#", "Name"]]); 39 | 40 | // Get the range for the table of contents entries. 41 | let worksheets = workbook.getWorksheets(); 42 | tocRange = tocRange.getResizedRange(worksheets.length, 0); 43 | 44 | // Loop through all worksheets in the workbook, except the first one. 45 | for (let i = 1; i < worksheets.length; i++) { 46 | // Create a row for each worksheet with its index and linked name. 47 | tocRange.getCell(i, 0).setValue(i); 48 | tocRange.getCell(i, 1).setHyperlink({ 49 | textToDisplay: worksheets[i].getName(), 50 | documentReference: `'${worksheets[i].getName()}'!A1` 51 | }); 52 | }; 53 | 54 | // Activate the table of contents worksheet. 55 | tocSheet.activate(); 56 | } 57 | ``` 58 | -------------------------------------------------------------------------------- /docs/resources/samples/table-of-contents.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/table-of-contents.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/table-with-filter.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/table-with-filter.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/tables-copy.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/tables-copy.xlsx -------------------------------------------------------------------------------- /docs/resources/samples/tables-select-copy.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/samples/tables-select-copy.xlsx -------------------------------------------------------------------------------- /docs/resources/scenarios/analyze-web-downloads.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/scenarios/analyze-web-downloads.xlsx -------------------------------------------------------------------------------- /docs/resources/scenarios/grade-calculator.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/scenarios/grade-calculator.xlsx -------------------------------------------------------------------------------- /docs/resources/scenarios/hr-schedule.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/scenarios/hr-schedule.xlsx -------------------------------------------------------------------------------- /docs/resources/scenarios/noaa-data-fetch.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Office Scripts sample scenario: Graph water-level data from NOAA' 3 | description: A sample that fetches JSON data from a NOAA database and uses it to create a chart. 4 | ms.date: 03/08/2022 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Office Scripts sample scenario: Fetch and graph water-level data from NOAA 9 | 10 | In this scenario, you need to plot the water level at the [National Oceanic and Atmospheric Administration's Seattle station](https://tidesandcurrents.noaa.gov/stationhome.html?id=9447130). You'll use external data to populate a spreadsheet and create a chart. 11 | 12 | You'll develop a script that uses the `fetch` command to query the [NOAA Tides and Currents database](https://tidesandcurrents.noaa.gov/). That will get the water level recorded across a given time span. The information will be returned as [JSON](https://www.w3schools.com/whatis/whatis_json.asp), so part of the script will translate that into range values. Once the data is in the spreadsheet, it will be used to make a chart. 13 | 14 | For more information about working with JSON, read [Use JSON to pass data to and from Office Scripts](../../develop/use-json.md). 15 | 16 | ## Scripting skills covered 17 | 18 | - External API calls (`fetch`) 19 | - JSON parsing 20 | - Charts 21 | 22 | ## Setup instructions 23 | 24 | 1. Open the workbook in Excel. 25 | 26 | 1. Under the **Automate** tab, select **New Script** and paste the following script into the editor. 27 | 28 | ```TypeScript 29 | /** 30 | * Gets data from the National Oceanic and Atmospheric Administration's Tides and Currents database. 31 | * That data is used to make a chart. 32 | */ 33 | async function main(workbook: ExcelScript.Workbook) { 34 | // Get the current sheet. 35 | let currentSheet = workbook.getActiveWorksheet(); 36 | 37 | // Create selection of parameters for the fetch URL. 38 | // More information on the NOAA APIs is found here: 39 | // https://api.tidesandcurrents.noaa.gov/api/prod/ 40 | const option = "water_level"; 41 | const startDate = "20201225"; /* yyyymmdd date format */ 42 | const endDate = "20201227"; 43 | const station = "9447130"; /* Seattle */ 44 | 45 | // Construct the URL for the fetch call. 46 | const strQuery = `https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?product=${option}&begin_date=${startDate}&end_date=${endDate}&datum=MLLW&station=${station}&units=english&time_zone=gmt&application=NOS.COOPS.TAC.WL&format=json`; 47 | 48 | console.log(strQuery); 49 | 50 | // Resolve the Promises returned by the fetch operation. 51 | const response = await fetch(strQuery); 52 | const rawJson: string = await response.json(); 53 | 54 | // Translate the raw JSON into a usable state. 55 | const stringifiedJson = JSON.stringify(rawJson); 56 | 57 | // Note that we're only taking the data part of the JSON and excluding the metadata. 58 | const noaaData: NOAAData[] = JSON.parse(stringifiedJson).data; 59 | 60 | // Create table headers and format them to stand out. 61 | let headers = [["Time", "Level"]]; 62 | let headerRange = currentSheet.getRange("A1:B1"); 63 | headerRange.setValues(headers); 64 | headerRange.getFormat().getFill().setColor("#4472C4"); 65 | headerRange.getFormat().getFont().setColor("white"); 66 | 67 | // Insert all the data in rows from JSON. 68 | let noaaDataCount = noaaData.length; 69 | let dataToEnter = [[], []] 70 | for (let i = 0; i < noaaDataCount; i++) { 71 | let currentDataPiece = noaaData[i]; 72 | dataToEnter[i] = [currentDataPiece.t, currentDataPiece.v]; 73 | } 74 | 75 | let dataRange = currentSheet.getRange("A2:B" + String(noaaDataCount + 1)); /* +1 to account for the title row */ 76 | dataRange.setValues(dataToEnter); 77 | 78 | // Format the "Time" column for timestamps. 79 | dataRange.getColumn(0).setNumberFormatLocal("[$-en-US]mm/dd/yyyy hh:mm AM/PM;@"); 80 | 81 | // Create and format a chart with the level data. 82 | let chart = currentSheet.addChart(ExcelScript.ChartType.xyscatterSmooth, dataRange); 83 | chart.getTitle().setText("Water Level - Seattle"); 84 | chart.setTop(0); 85 | chart.setLeft(300); 86 | chart.setWidth(500); 87 | chart.setHeight(300); 88 | chart.getAxes().getValueAxis().setShowDisplayUnitLabel(false); 89 | chart.getAxes().getCategoryAxis().setTextOrientation(60); 90 | chart.getLegend().setVisible(false); 91 | 92 | // Add a comment with the data attribution. 93 | currentSheet.addComment( 94 | "A1", 95 | `This data was taken from the National Oceanic and Atmospheric Administration's Tides and Currents database on ${new Date(Date.now())}.` 96 | ); 97 | 98 | /** 99 | * An interface to wrap the parts of the JSON we need. 100 | * These properties must match the names used in the JSON. 101 | */ 102 | interface NOAAData { 103 | t: string; // Time 104 | v: number; // Level 105 | } 106 | } 107 | ``` 108 | 109 | 1. Rename the script to **NOAA Water Level Chart** and save it. 110 | 111 | ## Running the script 112 | 113 | On any worksheet, run the **NOAA Water Level Chart** script. The script fetches the water level data from December 25, 2020 to December 27, 2020. The `const` variables at the beginning of the script can be changed to use different dates or get different station information. The [CO-OPS API For Data Retrieval](https://api.tidesandcurrents.noaa.gov/api/prod/) describes how to get all this data. 114 | 115 | ### After running the script 116 | 117 | :::image type="content" source="../../images/scenario-noaa-water-level-after.png" alt-text="The worksheet after running the script shows some water level data and a chart."::: 118 | -------------------------------------------------------------------------------- /docs/resources/scenarios/punch-clock-sample.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/scenarios/punch-clock-sample.xlsx -------------------------------------------------------------------------------- /docs/resources/scenarios/punch-clock.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Office Scripts sample scenario: Punch clock button' 3 | description: This sample adds a punch clock button and allows a user to clock in and clock out using the current time. 4 | ms.date: 02/07/2024 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Office Scripts sample scenario: Punch clock button 9 | 10 | The scenario idea and script used in this sample was contributed by Office Scripts community member [Brian Gonzalez](https://github.com/b-gonzalez). 11 | 12 | In this scenario, you'll create a time sheet for an employee that allows them to record their start and end times with a [button](../../develop/script-buttons.md). Based on what's previously been recorded, selecting the button will either start their day (clock in) or end their day (clock out). 13 | 14 | :::image type="content" source="../../images/punch-clock-sample-2.png" alt-text="A table with three columns ('Clock In', 'Clock Out', and 'Duration') and a button labeled 'Punch clock' in the workbook."::: 15 | 16 | ## Setup instructions 17 | 18 | 1. Download the sample workbook to your OneDrive. 19 | > [!div class="nextstepaction"] 20 | > [Download the sample workbook](punch-clock-sample.xlsx) 21 | 22 | :::image type="content" source="../../images/punch-clock-sample-1.png" alt-text="A table with three columns: 'Clock In', 'Clock Out', and 'Duration'."::: 23 | 24 | 1. Open the workbook in Excel. 25 | 26 | 1. Under the **Automate** tab, select **New Script** and paste the following script into the editor. 27 | 28 | ```typescript 29 | /** 30 | * This script records either the start or end time of a shift, 31 | * depending on what is filled out in the table. 32 | * It is intended to be used with a Script Button. 33 | */ 34 | function main(workbook: ExcelScript.Workbook) { 35 | // Get the first table in the timesheet. 36 | const timeSheet = workbook.getWorksheet("MyTimeSheet"); 37 | const timeTable = timeSheet.getTables()[0]; 38 | 39 | // Get the appropriate table columns. 40 | const clockInColumn = timeTable.getColumnByName("Clock In"); 41 | const clockOutColumn = timeTable.getColumnByName("Clock Out"); 42 | const durationColumn = timeTable.getColumnByName("Duration"); 43 | 44 | // Get the last rows for the Clock In and Clock Out columns. 45 | let clockInLastRow = clockInColumn.getRangeBetweenHeaderAndTotal().getLastRow(); 46 | let clockOutLastRow = clockOutColumn.getRangeBetweenHeaderAndTotal().getLastRow(); 47 | 48 | // Get the current date to use as the start or end time. 49 | let date: Date = new Date(); 50 | 51 | // Add the current time to a column based on the state of the table. 52 | if (clockInLastRow.getValue() as string === "") { 53 | // If the Clock In column has an empty value in the table, add a start time. 54 | clockInLastRow.setValue(date.toLocaleString()); 55 | } else if (clockOutLastRow.getValue() as string === "") { 56 | // If the Clock Out column has an empty value in the table, 57 | // add an end time and calculate the shift duration. 58 | clockOutLastRow.setValue(date.toLocaleString()); 59 | const clockInTime = new Date(clockInLastRow.getValue() as string); 60 | const clockOutTime = new Date(clockOutLastRow.getValue() as string); 61 | const clockDuration = Math.abs((clockOutTime.getTime() - clockInTime.getTime())); 62 | 63 | let durationString = getDurationMessage(clockDuration); 64 | durationColumn.getRangeBetweenHeaderAndTotal().getLastRow().setValue(durationString); 65 | } else { 66 | // If both columns are full, add a new row, then add a start time. 67 | timeTable.addRow() 68 | clockInLastRow.getOffsetRange(1, 0).setValue(date.toLocaleString()); 69 | } 70 | } 71 | 72 | /** 73 | * A function to write a time duration as a string. 74 | */ 75 | function getDurationMessage(delta: number) { 76 | // Adapted from here: 77 | // https://stackoverflow.com/questions/13903897/javascript-return-number-of-days-hours-minutes-seconds-between-two-dates 78 | 79 | delta = delta / 1000; 80 | let durationString = ""; 81 | 82 | let days = Math.floor(delta / 86400); 83 | delta -= days * 86400; 84 | 85 | let hours = Math.floor(delta / 3600) % 24; 86 | delta -= hours * 3600; 87 | 88 | let minutes = Math.floor(delta / 60) % 60; 89 | 90 | if (days >= 1) { 91 | durationString += days; 92 | durationString += (days > 1 ? " days" : " day"); 93 | 94 | if (hours >= 1 && minutes >= 1) { 95 | durationString += ", "; 96 | } 97 | else if (hours >= 1 || minutes > 1) { 98 | durationString += " and "; 99 | } 100 | } 101 | 102 | if (hours >= 1) { 103 | durationString += hours; 104 | durationString += (hours > 1 ? " hours" : " hour"); 105 | if (minutes >= 1) { 106 | durationString += " and "; 107 | } 108 | } 109 | 110 | if (minutes >= 1) { 111 | durationString += minutes; 112 | durationString += (minutes > 1 ? " minutes" : " minute"); 113 | } 114 | 115 | return durationString; 116 | } 117 | ``` 118 | 119 | 1. Rename the script to "Punch clock". 120 | 121 | 1. Save the script. 122 | 123 | 1. In the workbook, select cell **E2**. 124 | 125 | 1. Add a script button. Go to the **More options (…)** menu in the **Script details** page and select **Add in workbook**. 126 | 127 | 1. Save the workbook. 128 | 129 | ## Run the script 130 | 131 | Select the **Punch clock** button to run the script. It either logs the current time under "Clock In" or "Clock Out", depending on what was previously entered. 132 | 133 | :::image type="content" source="../../images/punch-clock-sample-2.png" alt-text="The table and the 'Punch clock' button in the workbook."::: 134 | 135 | > [!NOTE] 136 | > The duration is only recorded if it's longer than a minute. Manually edit the "Clock In" time to test larger durations. 137 | -------------------------------------------------------------------------------- /docs/resources/scenarios/task-reminders.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/resources/scenarios/task-reminders.xlsx -------------------------------------------------------------------------------- /docs/resources/vba-differences.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Differences between Office Scripts and VBA macros 3 | description: The behavior and API differences between Office Scripts and Excel VBA macros. 4 | ms.topic: product-comparison 5 | ms.date: 04/05/2023 6 | ms.localizationpriority: medium 7 | --- 8 | 9 | # Differences between Office Scripts and VBA macros 10 | 11 | Office Scripts and VBA macros have a lot in common. They both allow users to automate solutions through an easy-to-use action recorder and allow edits of those recordings. Both frameworks are designed to empower people who may not consider themselves programmers to create small programs in Excel. 12 | 13 | The fundamental difference is that VBA macros are developed for desktop solutions and Office Scripts are designed for secure, cross-platform, cloud-based solutions. 14 | 15 | :::image type="content" source="../images/office-programmability-diagram.png" alt-text="A four-quadrant diagram showing the areas of focus for different Office extensibility solutions. Both Office Scripts and VBA macros are designed to help end users create solutions. Office Scripts are built for cross-platform experiences and collaboration, whereas VBA is for the desktop."::: 16 | 17 | This article describes the main differences between VBA macros (as well as VBA in general) and Office Scripts. Since Office Scripts are only available for Excel, that is the only host being discussed here. 18 | 19 | ## Platform and ecosystem 20 | 21 | The following table shows which features are supported by which platforms and products. 22 | 23 | [!INCLUDE [Platform support table](../includes/platform-support-table.md)] 24 | 25 | VBA is designed to be desktop-centric. VBA can interact with a user's desktop to connect with similar technologies, such as COM and OLE. However, VBA has no convenient way to call out to the internet. Office Scripts use a universal runtime for JavaScript. This gives consistent behavior and accessibility, regardless of the machine being used to run the script. They can also make calls to [a limited set of web services](../develop/external-calls.md). 26 | 27 | Users require an enterprise or educational license to use or create Office Scripts. For the full list of supported licenses, see [Platform support](../testing/platform-limits.md#platform-support). VBA is built-in to the desktop versions of Excel and requires no special licensing. 28 | 29 | ## Security 30 | 31 | VBA macros have the same security clearance as Excel. This gives them full access to your desktop. Office Scripts only have access to the workbook, not the machine hosting the workbook. Additionally, no JavaScript authentication tokens can be shared with scripts. This means the script has neither the tokens of the signed-in user nor are there any API capabilities for signing in to an external service, so they are unable to use existing tokens to make external calls on behalf of the user. 32 | 33 | Admins have three options for VBA macros: allow all macros on the tenant, allow no macros on the tenant, or allow only macros with signed certificates. This lack of granularity makes it hard to isolate a single bad actor. Currently, Office Scripts can be off for an entire tenant, on for an entire tenant, or on for a group of users in a tenant. Admins also have control over who can share scripts with others and who can use scripts in Power Automate. 34 | 35 | ## Coverage 36 | 37 | Currently, VBA offers a more complete coverage of Excel features, particularly those available on the desktop client. Office Scripts cover nearly all of the scenarios for Excel on the web. Additionally, as new features debut on the web, Office Scripts will support them for both the Action Recorder and JavaScript APIs. 38 | 39 | Office Scripts don't support Excel-level [events](/office/vba/excel/concepts/events-worksheetfunctions-shapes/using-events-with-excel-objects). Scripts are only run when a user manually starts them or when a Power Automate flow calls the script. 40 | 41 | ## Power Automate 42 | 43 | VBA doesn't have a Power Automate connector. All supported VBA scenarios involve a user attending to the macro's execution. 44 | 45 | Office Scripts can be run through Power Automate. Your workbook can be updated through scheduled or event-driven flows, letting you automate workflows without even opening Excel. Try [Tutorial: Update a spreadsheet from a Power Automate flow](../tutorials/excel-power-automate-manual.md) to start learning about Power Automate. You can also check out the [Automated task reminders](scenarios/task-reminders.md) sample to see Office Scripts connected to Teams through Power Automate in a real-world scenario. 46 | 47 | ## See also 48 | 49 | - [Office Scripts in Excel](../overview/excel.md) 50 | - [Run Office Scripts with Power Automate](../develop/power-automate-integration.md) 51 | - [Differences between Office Scripts and Office Add-ins](add-ins-differences.md) 52 | - [Troubleshooting Office Scripts](../testing/troubleshooting.md) 53 | - [Excel VBA reference](/office/vba/api/overview/excel) 54 | -------------------------------------------------------------------------------- /docs/testing/undo.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Undo the changes made by Office Scripts 3 | description: Use the version history of Excel to undo the changes made by running a script. 4 | ms.date: 06/17/2024 5 | ms.localizationpriority: medium 6 | --- 7 | 8 | # Undo the changes made by Office Scripts 9 | 10 | You cannot undo changes made to the Excel workbook by a script with the Excel's **Undo** command. Instead, you must restore a previous version of the workbook from your cloud storage. 11 | 12 | ## Version history 13 | 14 | Office's version history is an easy way to restore an older workbook through the Excel UI. The feature only works for files stored in OneDrive or SharePoint Online. 15 | 16 | From the Excel workbook in which the script was run, use the following steps to undo the effects. 17 | 18 | 1. Go to **File** > **Info** > **Version History**. 19 | 1. Select a version saved prior to the running the script. 20 | 1. Select **Restore**. 21 | 22 | ## See also 23 | 24 | - [View previous versions of Office files](https://support.microsoft.com/office/5c1e076f-a9c9-41b8-8ace-f77b9642e2c2) 25 | -------------------------------------------------------------------------------- /docs/tutorials/excel-tutorial.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Tutorial: Create and format an Excel table" 3 | description: A tutorial about the basics of Office Scripts, including recording scripts with the Action Recorder and writing data to a workbook. 4 | ms.date: 09/20/2024 5 | ms.localizationpriority: high 6 | --- 7 | 8 | # Tutorial: Create and format an Excel table 9 | 10 | This tutorial teaches you the basics of recording, editing, and writing an Office Script for Excel. You'll record a script that applies some formatting to a sales record worksheet. You'll then edit the recorded script to apply more formatting, create a table, and sort that table. This record-then-edit pattern is an important tool to see what your Excel actions look like as code. 11 | 12 | ## Prerequisites 13 | 14 | [!INCLUDE [Tutorial prerequisites](../includes/tutorial-prerequisites.md)] 15 | 16 | > [!IMPORTANT] 17 | > This tutorial is intended for people with beginner to intermediate-level knowledge of JavaScript or TypeScript. If you're new to JavaScript, we recommend starting with the [Mozilla JavaScript tutorial](https://developer.mozilla.org/docs/Web/JavaScript/Guide/Introduction). Visit [Office Scripts Code Editor environment](../overview/code-editor-environment.md) to learn more about the script environment. 18 | 19 | ## Add data and record a basic script 20 | 21 | First, you'll need some data and a small starting script. 22 | 23 | 1. Create a new Excel workbook. 24 | 1. Copy the following fruit sales data and paste it into the worksheet, starting at cell **A1**. 25 | 26 | |Fruit |2018 |2019 | 27 | |:---|:---|:---| 28 | |Oranges |1000 |1200 | 29 | |Lemons |800 |900 | 30 | |Limes |600 |500 | 31 | |Grapefruits |900 |700 | 32 | 33 | 1. Open the **Automate** tab. If you don't see the **Automate** tab, check the ribbon overflow by selecting the drop-down arrow. If it's still not there, follow the advice in the article [Troubleshoot Office Scripts](../testing/troubleshooting.md#automate-tab-not-appearing-or-office-scripts-unavailable). 34 | 1. Select the **Record Actions** button. 35 | 1. Select cells **A2:C2** (the "Oranges" row) and set the fill color to orange. 36 | 1. Stop the recording by selecting the **Stop** button. 37 | 38 | Your worksheet should look like this (don't worry if the color is different): 39 | 40 | :::image type="content" source="../images/tutorial-1.png" alt-text="A worksheet showing fruit sales data row with the row containing 'Oranges' highlighted in the color orange."::: 41 | 42 | ## Edit an existing script 43 | 44 | The previous script colored the "Oranges" row to be orange. Add a yellow row for the "Lemons". 45 | 46 | 1. From the now-open **Details** pane, select the **Edit** button. 47 | 1. You should see something similar to this code: 48 | 49 | ```TypeScript 50 | function main(workbook: ExcelScript.Workbook) { 51 | // Set fill color to FFC000 for range Sheet1!A2:C2 52 | let selectedSheet = workbook.getActiveWorksheet(); 53 | selectedSheet.getRange("A2:C2").getFormat().getFill().setColor("FFC000"); 54 | } 55 | ``` 56 | 57 | This code gets the current worksheet from the workbook. Then, it sets the fill color of the range **A2:C2**. 58 | 59 | Ranges are a fundamental part of Office Scripts in Excel. A range is a contiguous, rectangular block of cells that contains values, formula, and formatting. They are the basic structure of cells through which you'll perform most of your scripting tasks. 60 | 61 | 1. Add the following line to the end of the script (between where the `color` is set and the closing `}`): 62 | 63 | ```TypeScript 64 | selectedSheet.getRange("A3:C3").getFormat().getFill().setColor("yellow"); 65 | ``` 66 | 67 | 1. Test the script by selecting **Run**. Your workbook should now look like this: 68 | 69 | :::image type="content" source="../images/tutorial-2.png" alt-text="A worksheet showing the fruit sales data row with the 'Oranges' row highlighted in the color orange and the 'Lemons' row highlighted in the color yellow."::: 70 | 71 | ## Create a table 72 | 73 | Next, convert this fruit sales data into a table. You'll keep modifying the first script for the entire tutorial. 74 | 75 | 1. Add the following line to the end of the script (before the closing `}`): 76 | 77 | ```TypeScript 78 | let table = selectedSheet.addTable("A1:C5", true); 79 | ``` 80 | 81 | 1. That call returns a `Table` object. Use that table to sort the data. Sort the data in ascending order based on the values in the "Fruit" column. Add the following line after the table creation: 82 | 83 | ```TypeScript 84 | table.getSort().apply([{ key: 0, ascending: true }]); 85 | ``` 86 | 87 | Your script should look like this: 88 | 89 | ```TypeScript 90 | function main(workbook: ExcelScript.Workbook) { 91 | // Set fill color to FFC000 for range Sheet1!A2:C2 92 | let selectedSheet = workbook.getActiveWorksheet(); 93 | selectedSheet.getRange("A2:C2").getFormat().getFill().setColor("FFC000"); 94 | selectedSheet.getRange("A3:C3").getFormat().getFill().setColor("yellow"); 95 | let table = selectedSheet.addTable("A1:C5", true); 96 | table.getSort().apply([{ key: 0, ascending: true }]); 97 | } 98 | ``` 99 | 100 | Tables have a `TableSort` object, accessed through the `Table.getSort` method. You can apply sorting criteria to that object. The `apply` method takes in an array of `SortField` objects. In this case, you only have one sorting criteria, so you only use one `SortField`. The `key: 0` value sets the column with the sort-defining values to "0" (which is the first column on the table, column **A** in this case). The `ascending: true` value sorts the data in ascending order (instead of descending order). 101 | 102 | 1. Run the script. You should see a table like this: 103 | 104 | :::image type="content" source="../images/tutorial-3.png" alt-text="A worksheet showing the sorted fruit sales table."::: 105 | 106 | > [!NOTE] 107 | > If you re-run the script, you'll get an error. This is because you can't create a table on top of another table. However, you can run the script in a different worksheet or workbook. 108 | 109 | ### Re-run the script 110 | 111 | 1. Create a new worksheet in the current workbook. 112 | 1. Copy the fruit data from the beginning of the tutorial and paste it into the new worksheet, starting at cell **A1**. 113 | 1. Run the script. 114 | 115 | ## Next steps 116 | 117 | Complete [Tutorial: Clean and normalize Excel workbook data](excel-read-tutorial.md). It teaches you how to read data from a workbook with an Office Script. 118 | -------------------------------------------------------------------------------- /docs/tutorials/on-call-rotation.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/office-scripts-docs/bba5998f5c3d06362a919b8ea5c2a8dc3685364c/docs/tutorials/on-call-rotation.xlsx --------------------------------------------------------------------------------