Reputation: 126
We are developing an excel add-in with react and office js APIs. We have added a chart and set the color to the chart from the color palette(chart-design -> Change Colours -> Colourful palette4).
Please refer the below screenshot ->
We wanted to get the color palette name or colors set to the chart. We checked through the office js documentation https://learn.microsoft.com/en-us/javascript/api/excel/excel.chart?view=excel-js-preview, We can get Style for the chart but we are not able to find anything related to getting a color palette.
Can anyone please help us to understand how to get a color palette using office js APIs?
Upvotes: 2
Views: 490
Reputation: 2236
You can use colorScheme
API under ChartAreaFormat
, here is a sample code to get the color scheme
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
const chart = sheet.charts.getItemAt(0);
chart.load("format/colorScheme");
await context.sync();
console.log(chart.format.colorScheme);
});
Upvotes: 3