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
selectedSheet.getRange("D2:H3").setFormulasLocal([["=WENN(C2=1;C2;-2)","=WENN(UND(C2<1;C2>0,85);C2;-2)","=WENN(UND(C2<0,9;C2>0,75);C2;-2)","=WENN(C2>0,8;C2;-2)","1"],[null,null,"",null,"2"]]);
// Set range H4 on selectedSheet
selectedSheet.getRange("H4").setValue("3");
// Auto fill range
selectedSheet.getRange("H2:H4").autoFill();
// Set range G2 on selectedSheet
selectedSheet.getRange("G2").setFormulaLocal("=WENN(C2<0,8;C2;-2)");
var waitUntil = new Date().getTime() + 2000;
while (new Date().getTime() < waitUntil) { };
let diagramm_1 = selectedSheet.getChart("Diagramm 1");
let Pointimage = diagramm_1.getImage();
selectedSheet.getRange("A33").setValue(diagramm_1.getChartType());
return {Pointimage};
}
In Power Automate, the image is extracted as follows:
{
"$content_type": "image/png",
"$content": @{outputs('Skript_ausführen')?['body/result']?['Pointimage']}
}