Office Scripts samples and scenarios
This section contains Office Scripts based automation solutions that help end users achieve automation of daily tasks. It contains realistic scenarios that business users face and provides detailed solutions along with step-by-step instructional video links.
In Scenarios, we have included a few larger scenario samples that demonstrate real-world use cases.
We also welcome contributions from the community.
|Scripting basics||These samples demonstrate fundamental building blocks for Office Scripts.|
|Add comments in Excel||This sample adds comments to a cell including @mentioning a colleague.|
|Add images to a workbook||This sample adds an image to a workbook and copies an image across sheets.|
|Copy multiple Excel tables into a single table||This sample combines data from multiple Excel tables into a single table that includes all the rows.|
Beyond the basics
Check out the following end-to-end project that automates sample scenarios along with full scripts, sample Excel files used, and videos (hosted on YouTube).
|Count blank rows in a specific sheet or in all sheets||This sample detects if there are any blank rows in sheets where you anticipate data to be present and then report the blank row count for usage in a Power Automate flow.|
|Email chart and table images||This sample uses Office Scripts and Power Automate actions to create a chart and send that chart as an image by email.|
|External fetch calls||This sample uses
|Filter Excel table and get visible range||This sample filters an Excel table and returns the visible range as a JSON object. This JSON could be provided to a Power Automate flow as part of a larger solution.|
|Manage calculation mode in Excel||This sample shows how to use the calculation mode and calculate methods in Excel on the web using Office Scripts.|
|Move rows across tables||This sample shows how to move rows across tables by saving filters, then processing and reapplying the filters.|
|Output Excel data as JSON||This solution shows how to output Excel table data as JSON to use in Power Automate.|
|Remove hyperlinks from each cell in an Excel worksheet||This sample clears all of the hyperlinks from the current worksheet.|
|Run a script on all Excel files in a folder||This project performs a set of automation tasks on all files situated in a folder on OneDrive for Business (can also be used for a SharePoint folder). It performs calculations on the Excel files, adds formatting, and inserts a comment that @mentions a colleague.|
|Write a large dataset||This sample shows how to send a large range as smaller subranges.|
Office Scripts can automate parts of your daily routine. These day-to-day tasks often exist in unique ecosystems, with Excel workbooks that are set up in particular ways. These larger scenario samples demonstrate such real-world use-cases. They include both the Office Scripts and the workbooks, so you can see the scenario from end to end.
|Analyze web downloads||This scenario features a script that parses web traffic records to determine a user's country of origin. It showcases the skills of text parsing, using subfunctions in scripts, applying conditional formatting, and working with tables.|
|Fetch and graph water-level data from NOAA||This scenario uses an Office Script to pull data from an external source (the NOAA Tides and Currents database) and graph the resulting information. It highlights the skills of using
|Grade calculator||This scenario features a script that validates an instructor's record for their class's grades. It showcases the skills of error checking, cell formatting, and regular expressions.|
|Schedule interviews in Teams||This scenario shows how to use an Excel spreadsheet to manage interview meeting times and make a flow to schedules meetings in Teams.|
|Task reminders||This scenario uses an Office Script in a Power Automate flow to send reminders to coworkers to update a project's status. It highlights the skills of Power Automate integration and data transfer to and from scripts.|
Community contributions and fun samples
We welcome contributions from our Office Scripts community! Feel free to create a pull request for review.
|Game of Life||The "Ready Player Zero" blog by Yutao Huang on the Excel Tech Community includes a script to model John Conway's The Game of Life.|
|Seasons greetings animation||This script was contributed by Leslie Black in the spirit of the holiday season! It's a fun script that shows a singing Christmas tree in Excel on the web using Office Scripts.|
Try it out
These samples are open source. Try them out yourself. You'll need a Microsoft work or school account from work or school with a license to Microsoft 365 subscription (E3 or above). Just head over to https://office.com to sign in to your account and get started.
Leave a comment
Feel free to leave a comment, make a suggestion, or log an issue by using the Feedback section at the bottom of the specific sample's documentation page.