Grid::MergeCells

Description

To merge cells.

Syntax

BOOL        MergeCells(const ORANGE& rng, BOOL bLabels = FALSE, BOOL bMerge = TRUE)

Parameters

rng
[input] the range of cells to do merge.
bLabels
[input] if it is TRUE, then range will not get offset, therefore labels area could be specified.
bMerge
[input] if FALSE, un-merge cells within selected range.

Return

TRUE if successfully else FALSE.

This function will always return TRUE unless you try to merge the same range twice (even if the range is invalid).

Examples

EX1

void Grid_MergeCells_ex1()
{
        Worksheet wks;
        wks.Create("Origin");
        
        Grid gg;
        gg.Attach(wks);  
        
        // to merge the first two rows in two columns
        ORANGE rng;
        rng.r1 = 0;
        rng.c1 = 0;
        rng.r2 = 1;
        rng.c2 = 1;
        gg.MergeCells(rng);
}

EX2

void Grid_MergeCells_ex2()
{
        Worksheet wks;
        wks.Create("Origin"); // make sure there are at least two columns labels
        
        Grid gg;
        gg.Attach(wks);  
        
        // to merge the first two rows in first two column labels area
        ORANGE rng;
        rng.r1 = 0;
        rng.c1 = 0;
        rng.r2 = 1;
        rng.c2 = 1;
        gg.MergeCells(rng, true); // merge cells
        gg.MergeCells(rng, true, false); // un-merge cells
}

Remark

See Also

header to Include

origin.h