getSeries() does not work in Excel scripts

Raymond 0 Reputation points
2024-04-24T14:06:45.0233333+00:00

Hi,

I got an issue with using the getSeries() function in excel script.

I want to write script to change the color of the pie chart. I did it manually and I recorded it.

The below is the code:

function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
let TestingChart = selectedSheet.getChart("TestingChart");
// Set fill color on series for a chart
TestingChart.getSeries()[0].getFormat().getFill().setSolidColor("#FF0000");
}

However, when I try to run it again. I got error "Chart getSeries: The requested resource doesn't exist."

the chart is a pie chart and I am pretty sure the chart contains some series on it.

Thank you.

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
1,477 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
872 questions
0 comments No comments
{count} votes