Can we choose value for mergeCells

Tags: #<Tag:0x00007efc64f73408>

Yeah, we merge a1,b1,a2,b2. as default we will get value a1 in mergeCell but i want get another value like a2 or b2 instead of a1. Can you recommend solutions?

Hi @doanak000

the mergeCells plugin does not allow you to pick a value. But you can try to alter the first cell in a range before the merging eds. To do that you can use the beforeMergeCells() hook. Here’s an example https://jsfiddle.net/o3au91mf/1/

When the user merges cells you are provided with a range of cells that take part in the merging.

14
(sample output)

So if you decide that you do not want to want the upper left value in the merged area but (example) a bottom right value you’ll need to use setDataAtCell(row_index, column_index) using the to.row and to.col values.