Reputation: 1
I am generating a D3JS Chart from excel data within an Office Addin (office-js) as a svg. Now I have trouble to add the SVG into the excel sheet.
Will this work with an office addin?
Upvotes: 0
Views: 955
Reputation: 49445
The problem is that vector file formats are not supported in Office. In fact if you try to insert an *.svg image directly from the insert->pictures functionality in Excel, you will see that the image will not be inserted as you expect. That's true for Excel Online as well.
I'd suggest you to try jpg, jpeg, png, gif, bmp, tif or tiff formats instead.
You may try using the following code:
const svgIsSupported = Office.context.requirements.isSetSupported('ImageCoercion', 1.2);
if (svgIsSupported){
Office.context.document.setSelectedDataAsync(svgImage, { coercionType: Office.CoercionType.XmlSvg }, (result) => {
console.log(result);
});
}
}
See Inserting an SVG image for more information.
Upvotes: 1