> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-+-++/modules/bx-spreadsheet/built-in-functions/spreadsheetmergecells.md).

# SpreadsheetMergeCells

Merges a rectangular block of two or more Excel spreadsheet object cells.

## Method Signature

```
SpreadsheetMergeCells(spreadsheetObj=[any], startRow=[any], startColumn=[any], endRow=[any], endColumn=[any])
```

### Arguments

| Argument         | Type      | Required | Description                           | Default |
| ---------------- | --------- | -------- | ------------------------------------- | ------- |
| `spreadsheetObj` | `ANY`     | `true`   | The spreadsheet object.               |         |
| `startRow`       | `NUMERIC` | `true`   | The starting row number (1-based).    |         |
| `startColumn`    | `NUMERIC` | `true`   | The starting column number (1-based). |         |
| `endRow`         | `NUMERIC` | `true`   | The ending row number (1-based).      |         |
| `endColumn`      | `NUMERIC` | `true`   | The ending column number (1-based).   |         |

## Examples

Merge cells for titles:

```js
// Merge cells A1:D1 for title
var spreadsheet = SpreadsheetNew();
SpreadsheetAddRow( spreadsheet, [ "Report Title", "", "", "" ] );

SpreadsheetMergeCells( spreadsheet, 1, 1, 1, 4 );
SpreadsheetFormatCell( spreadsheet, 1, 1, { bold = true, alignment = "center" } );
```

## Related

* [SpreadsheetFormatCell()](/boxlang-+-++/modules/bx-spreadsheet/built-in-functions/spreadsheetformatcell.md) - Format cell
* [SpreadsheetFormatCellRange()](/boxlang-+-++/modules/bx-spreadsheet/built-in-functions/spreadsheetformatcellrange.md) - Format range
* [Formatting Guide](/boxlang-+-++/modules/bx-spreadsheet/formatting.md) - Cell styling


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-+-++/modules/bx-spreadsheet/built-in-functions/spreadsheetmergecells.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
