# encodeRange

Source: /xlsx-format/api-reference/functions/encoderange

Encode a Range or pair of CellAddresses to an A1:B2 range string.

Can be called as:
- `encodeRange(range)` with a Range object
- `encodeRange(start, end)` with two CellAddress objects

If start and end are the same cell, returns a single cell reference (no colon).

```ts
encodeRange(cs: CellAddress | Range, ce?: CellAddress): string
```

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| ` cs ` | [` CellAddress `](</xlsx-format/api-reference/interfaces/celladdress/>) ` \| ` [` Range `](</xlsx-format/api-reference/interfaces/range/>) | Yes | A Range object, or the start CellAddress |
| ` ce ` | [` CellAddress `](</xlsx-format/api-reference/interfaces/celladdress/>) | No | Optional end CellAddress (when cs is a CellAddress) |

## Returns

` string `

Range string in A1 notation (e.g. "A1:B2" or "A1")
