MergeCells
To merge cells.
BOOL MergeCells(const ORANGE& rng, BOOL bLabels = FALSE, BOOL bMerge = TRUE)
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).
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 }
origin.h