Worksheet Merge Cells

 

Version Info

Minimum Origin Version Required: Origin8.1 SR1

Merge Cells

This example shows how to merge cells in worksheet

void wks_merge_cells_ex()
{
    Worksheet wks;
    wks.Create("Origin");
    //Define a Grid and attach it to the worksheet
    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;
    
    bool bRet = gg.MergeCells(rng);
    
    if( bRet )
        printf("Successfully merged cells in %s!\n", wks.GetName());
    else
        printf("Failed to merge cells in %s!\n", wks.GetName());
}

See also: Grid::MergeCells

Merge Column Labels Area

This example shows how to merge column label area in worksheet

void wks_merge_col_labels_area_ex()
{
        Worksheet wks;
    wks.Create("Origin");
    
    //Define a Grid and attach it to the worksheet
    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;
 
    bool bLabels = true;
    bool bRet = gg.MergeCells(rng, bLabels);
    
        if( bRet )
        printf("Successfully merged cells in %s!\n", wks.GetName());
    else
        printf("Failed to merge cells in %s!\n", wks.GetName());
}