Skip to content
Julian Halliwell edited this page Sep 20, 2021 · 6 revisions

Merges a block of cells.

mergeCells( workbook, startRow, endrow, startColumn, endColumn[, emptyInvisibleCells ] )

Required arguments

  • workbook spreadsheet object
  • startRow numeric
  • endRow numeric
  • startColumn numeric
  • endColumn numeric

Optional arguments

  • emptyInvisibleCells boolean default=false: Whether to set the invisible merged cells to an empty string instead of keeping the original value.

Chainable? Yes.

Note

The merged cell by default displays the value in the cell that is on the left-most and top-most side of the spreadsheet. For example, if you merge the cell (20,3) and cell (20,4), then the value in the cell (20,3) is displayed. If the cell (20,3) is blank, then after merging, the cell displays blank.

The other merged cells will retain their original values in the underlying workbook, unless you use the emptyInvisibleCells option.

Example

data = QueryNew( "First,Last","VarChar,VarChar",[ [ "Susi","Sorglos" ],[ "Frumpo","McNugget" ] ] );
spreadsheet = New spreadsheet();
workbook = spreadsheet.workbookFromQuery( data );
// merge rows 2 and 3 of column 1
spreadsheet.mergeCells( workbook, 2, 3, 1, 1 );
Clone this wiki locally