

The Excel Worksheet with two data sets The FlowĬalling the Excel Office Script from Power Automate is done from the “Run Script” action. I often start by recording the steps I am looking to automate and then repurpose the code to suit my exact requirements. Here you can record a script or start from scratch if you are confident with TypeScript. The automate tab of Excel is only available Online, don’t go looking for it on the Desktop client. Whilst the script can be tested and called from within Excel Online, it can be triggered from a Flow. Let linechartimage = linechart.getImage() Linechart.getTitle().setText('Total Solutions in June 2021') Piechart.getTitle().setText('Favourite PowerPlatform Tool')

Let piechart = selectedSheet.addChart(, selectedSheet.getRange('D4:E9')) Insert pie chart on sheet selectedSheet Let linechart = selectedSheet.addChart(, selectedSheet.getRange('A1:B31')) Insert line chart on sheet selectedSheet Let selectedSheet = workbook.getWorksheet("June") function main(workbook: ExcelScript.Workbook You’ll note that both images are returned to the Flow as an array.

Using the getImage() function we can create a base64 representation of the Chart. Note these data sets do not have to be defined as tables. We then create both a line chart and a pie chart on two different data sets. Below, we assume that our worksheet is called June.

Equally, you can apply a filter on the data and run the addchart() function on the filtered data. The script below assumes that data is already in the sheet and the range is fixed BUT you can dynamically identify the column & row range in use for the creation of Charts. I have a couple of videos ( at the bottom of the page) demonstrating the creation of Charts from Excel using Office Scripts. Embed the charts into Word, HTML, or permanent PDF files using Premium or regular actions. Send the chart(s) to external users via email. Did you know that you can automatically create dynamic charts (Pie / Column / Bar) using data in Excel by using Office Scripts and Power Automate? These charts can be created and returned as images to Power Automate and then used in any document of your choice.
