Power Automate: Office Script in Excel doesn't Chart as Image

Stadelmann Lukas 1 Reputation point

In Power Automate I trigger an office script in Excel, that updates a bubble chart.
This Chart should then be returned to the automate flow and populates a Word.

The Script seems to work properly, as it does return data, but the Word document refuses the data with the error code:

The image is not of type PNG or JPG. Please provide an image of type PNG or JPG.

function main(workbook: ExcelScript.Workbook) {  
	let selectedSheet = workbook.getActiveWorksheet();  
	// Set range D2:H3 on selectedSheet  
	// Set range H4 on selectedSheet  
	// Auto fill range  
	// Set range G2 on selectedSheet  
	var waitUntil = new Date().getTime() + 2000;  
	while (new Date().getTime() < waitUntil) { };  
	let diagramm_1 = selectedSheet.getChart("Diagramm 1");  
	let Pointimage = diagramm_1.getImage();  
	return {Pointimage};  

In Power Automate, the image is extracted as follows:

  "$content_type": "image/png",  
  "$content": @{outputs('Skript_ausführen')?['body/result']?['Pointimage']}  
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,662 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Geoff Ren 1 Reputation point Microsoft Employee

    From the documentation of the chart.getImage() function: Renders the chart as a base64-encoded image. So you need to pass it in a different format. Can you try the solution posted here and see if that works?

    I would also recommend testing by logging out the image string and using that directly. Just so you can isolate the area that you are trying to test better.

    0 comments No comments

  2. Anonymous

    Power automate is not currently supported here on Q&A. The product group for Power automate actively monitors questions in dedicated forums here.

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments