SpreadJS 15
Features / Cells / Drag and Merge
In This Topic
    Drag and Merge
    In This Topic

    SpreadJS supports the drag and merge operation by allowing users to select cells and drag the selection to merge cells.

    Drag and merge operation provides a great way when you want to create a new, larger cell using other cells in a spreadsheet or simply when you need to create a label that spans several columns or rows.

    The allowUserDragMerge option of the workbook can be used to control whether or not to allow users to merge cells via mouse drag.

    By default, the allowUserDragMerge option is set to boolean false and the cells behave in normal mode. However, when this option is set to true, an indicator in the selection border will appear as shown in the below image.

     Drag merge opeartion in SpreadJS

    Using Code

    This example shows how to allow users to perform the drag merge operation. The options.allowUserDragMerge property is used to specify whether to allow the drag merge operation in the worksheet.

    Copy Code
    // Allow users to merge cells via mouse drag   
    spread.options.allowUserDragMerge = true;    

    For more information, please refer to Cell Span.


    The drag merge operation has the following limitations:

    • The drag cannot cross a span.
    • The drag and merge only works to the right or down.
    • The indicator color is the same as the selection border.
    • The drag and merge operation cannot be executed if the selected range by a user contains a partially spanned cell range.