1

I am able to merge cells of the same row using Excel JS Api like this

let B2F2cellRange = sheet.getRange("B2:F2");
B2F2cellRange.merge(true);

But once I try to merge an area like this: sheet.getRange("B2:F3") it fails. Any idea? Is it a limitation of the Api?

2 Answers2

1

Not sure what the error is when you failed to merge an area like sheet.getRange("B2:F3"). I have a gist to perform the same operation, which works for me. You may can have a try then.

xiaochun
  • 114
  • 5
1

There are 2 behaviors for this API. I guess you may want to tryrange.merge(false) behavior:

  1. range.merge(false)

enter image description here

  1. range.merge(true)

enter image description here

The doc can be found at https://learn.microsoft.com/en-us/javascript/api/excel/excel.range?view=excel-js-preview#merge-across-

Raymond Lu
  • 2,178
  • 1
  • 6
  • 19