Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
JavaScript Excel - How to specify spaces in dataSource worksheet name

I have a worksheet called "My Sheet" with data I want to use as the datasource for a chart.

If I code chart.setSourceData('My Sheet!A1:M9',true) or char.setSourceData("'My Sheet'!A1:M9,true), I get an error. The only way to get it to work is to remove all spaces from the worksheet name, but I want the worksheet name to have some spaces to make it more readable.

Even though the worksheet name can also include other characters, like a dash or comma, having those in the specified worksheet name when calling the setSourceData method causes errors.

How can I use data from a worksheet in the setSourceData method when the worksheet name contains blanks and other allowed characters?