[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IWorksheet.AutoMerge

AutoMerge Method

AutoMerge(IRange, AutoMergeDirection, AutoMergeMode, AutoMergeSelectionMode)

Applies auto merge to the specified range by using the specified or default direction, mode, and selection mode.

This method adds auto-merge information to the specified range so that adjacent cells with the same value can be merged automatically. If direction is None, the existing auto merge for the range is canceled.

Declaration
void AutoMerge(IRange range, AutoMergeDirection direction = AutoMergeDirection.Column, AutoMergeMode mode = AutoMergeMode.Free, AutoMergeSelectionMode selectionMode = AutoMergeSelectionMode.Source)
Sub AutoMerge(range As IRange, Optional direction As AutoMergeDirection = AutoMergeDirection.Column, Optional mode As AutoMergeMode = AutoMergeMode.Free, Optional selectionMode As AutoMergeSelectionMode = AutoMergeSelectionMode.Source)
Parameters
Type Name Description
IRange range

The range to which auto-merge information is applied.

AutoMergeDirection direction

The direction used to evaluate and apply auto merge. Use None to cancel auto merge for the range.

AutoMergeMode mode

The auto merge mode that determines how matching cells are merged.

AutoMergeSelectionMode selectionMode

The auto merge selection mode that determines which cell value is kept after merging.

Examples
IRange range = worksheet.Range["A1:A4"];
range.Value = new object[,] {
    {"Fruit"}, {"Fruit"}, {"Vegetable"}, {"Vegetable"}
});
worksheet.AutoMerge(range, AutoMergeDirection.Column);