Using the Excel Javascript API, I'd like to copy values and formatting from one rangeAreas object to another with equal dimensions. According to the docs, copyFrom should work the same with rangeAreas as it does with ranges. But I'm getting an error:
RichApi.Error: The argument is invalid or missing or has an incorrect format.
I expect this to write values, formats, etc. from cells B8 & B10 to G8 & G10:
await Excel.run(async (context) => {
let s = context.workbook.worksheets.getActiveWorksheet();
let sourceRanges = s.getRanges("B8, B10");
let destinationRanges = s.getRanges("G8, G10");
sourceRanges.format.fill.color = "pink"; // this DOES work, so sourceRanges is somewhat functional
await context.sync();
destinationRanges.copyFrom(sourceRanges); // RichApi.Error: The argument is invalid or missing or has an incorrect format.
await context.sync();
});
I have also tried without success:
- adding more or fewer
context.sync()s - adding optional params to
copyFromto override defaults
I am using MS365 v2407 and the Excel JS API v1.16
