A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
When trying to store escaped strings in a workbook level range name in Excel Online, it throws an error.
The exact same code works fine in Excel for desktop on Windows.
The following code gives an error when running in Excel Online:
Trying to store metadata in a workbook level range name, in the form of an escaped JSON object.
Useful logs
[x] Console errors
Console error:
[ERROR]: Error:
{
"stack": "RichApi.Error: The argument is invalid or missing or has an incorrect format.\n at new n (https://appsforoffice.microsoft.com/lib/1/hosted/excel-web-16.00.js:25:317442)\n at i.processRequestExecutorResponseMessage (https://appsforoffice.microsoft.com/lib/1/hosted/excel-web-16.00.js:25:381888)\n at https://appsforoffice.microsoft.com/lib/1/hosted/excel-web-16.00.js:25:379951",
"message": "The argument is invalid or missing or has an incorrect format.",
"name": "RichApi.Error",
"code": "InvalidArgument",
"traceMessages": [],
"innerError": null,
"debugInfo": {
"code": "InvalidArgument",
"message": "The argument is invalid or missing or has an incorrect format.",
"errorLocation": "NamedItemCollection.add",
"statement": "var add = names.add(...);",
"surroundingStatements": [
"var workbook = context.workbook;",
"var names = workbook.names;",
"// >>>>>",
"var add = names.add(...);",
"// <<<<<"
],
"fullStatements": [
"var workbook = context.workbook;",
"var names = workbook.names;",
"var add = names.add(\"Test_Range\", \"Hello \\\"Excel\\\" world!\", undefined);"
]
},
"httpStatusCode": 400
}
Description
When trying to store escaped strings in a workbook level range name in Excel Online, it throws an error. The exact same code works fine in Excel for desktop on Windows.
The following code gives an error when running in Excel Online:
It still fails when trying variations of the
...add
line such as:Giving the following error:
Your Environment
Expected behavior
Expect the code to work, as it does on Excel for desktop on Windows.
Current behavior
An error is thrown.
Steps to reproduce
Link to live example(s)
N/A
Provide additional details
N/A
Context
Trying to store metadata in a workbook level range name, in the form of an escaped JSON object.
Useful logs
Console error: