OfficeDev / office-js

A repository for issues related to the Office JavaScript APIs and Office Add-ins platform. Find the Office.js library in Office.js CDN: https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
725 stars 106 forks source link

How to read and update chart data (series ) through powerpoint Api. #5463

Closed shermaro91 closed 1 month ago

shermaro91 commented 1 month ago

I am developing an add-in using the PowerPoint API and have inserted a chart via the ribbon tab. I successfully located the chart through Office.js with the code provided below.

async function run() { await PowerPoint.run(async (context) => { debugger; const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes; shapes.load("type"); await context.sync(); // Change the shape transparency to be halfway transparent. shapes.items.forEach((shape) => { if (shape.type === PowerPoint.ShapeType.chart) {

  }
});

}); } However, I am unable to read the chart data. Is there a property or method available that allows me to read and update the chart data? If it is there then please guide me through it or else is there any other alternative way to read the data then also suggest.

My Environment Platform : PC desktop Host: Word Office version number: Microsoft® PowerPoint® for Microsoft 365 MSO (Version 2501 Build 16.0.18429.20132) 64-bit Operating System: Windows 11

isabela-dominguez commented 1 month ago

Thank you for sharing this issue @shermaro91. Connecting you with @EsterBergen who may be able to help. In the future, please direct all programming questions to https://stackoverflow.com/questions/tagged/office-js

EsterBergen commented 1 month ago

Thank you @shermaro91 for the issue! The ability to work with charts in Office.js is very limited. You're correct that there is a shape type chart, however you can not read or write charts in powerpoint programatically at this time. Please make a feature request here Microsoft 365 Developer Platform Ideas Forum. Please add your request there. Feature requests on are considered when we go through our planning process. Thanks for highlighting this!

shermaro91 commented 1 month ago

Hi @EsterBergen, thanks for sharing this. I understand that there isn't a direct method to read or write charts in PowerPoint at the moment. However, is there an alternative way to achieve this?

EsterBergen commented 2 weeks ago

@shermaro91 - Not that I know of. You can insert a shape and use the ShapeFill setImage(base64EncodedImage: string) preview API for an image of the chart.