Office Scripts Tutorial: Automate a Weekly Excel Report
Read the full guideWatch on YouTubeMore fixes on the EpiFive channel
About this video
Write an Office Script that totals last week's sales by region, writes a formatted summary sheet and returns the figures to a scheduled Power Automate flow that emails them.
This tutorial walks through the steps of the full guide on screen; the chapters below jump to each part.
Chapters
- 0:00 What this video covers
- 0:17 Prepare the SalesData table
- 1:09 Open the Code Editor
- 1:40 Write main and read the table
- 2:27 Filter and total the last seven days
- 3:14 Rewrite the Weekly Summary sheet
- 3:50 Return the summary to Power Automate
- 4:18 Run the script and check the output
- 5:30 Add the Recurrence trigger
- 6:06 Add the Run script action
- 6:48 Email the report and test it
- 7:39 Recap
Key points
- An Office Script starts from function main(workbook: ExcelScript.Workbook), and any extra parameters or return type become input fields and dynamic content in the Power Automate Run script action.
- Excel stores dates as serial numbers, so compare whole serial days in the script and pass the report date from the flow, because Power Automate runs scripts in UTC.
- The Run script action is limited to 1,600 calls per user per day and 3 calls per 10 seconds, and synchronous flow operations time out after 120 seconds.
- Run script only lists scripts stored in your OneDrive; scripts saved in a SharePoint library need the Run script from SharePoint library action instead.
- If you change a script's parameters or return type, remove the Run script action and add it again so the flow picks up the new signature.
In the full guide
Office Scripts: Automate a Weekly Excel Report With Power Automate (20 min read, Microsoft 365)
- Who this is for and what you will build
- Requirements and licensing
- Office Scripts basics before you start
- Step 1: Prepare the SalesData table
- Step 2: Create the script in the Code Editor
- How the script handles dates and return values
- Step 3: Run the script in Excel and check the output
- Step 4: Build the scheduled flow



