--- sidebar_position: 1 title: Addresses and Ranges --- ## Cell Addresses Cell address objects are stored as `{c:C, r:R}` where `C` and `R` are 0-indexed column and row numbers, respectively. For example, the cell address `B5` is represented by the object `{c:1, r:4}`. ## Cell Ranges Cell range objects are stored as `{s:S, e:E}` where `S` is the first cell and `E` is the last cell in the range. The ranges are inclusive. For example, the range `A3:B7` is represented by the object `{s:{c:0, r:2}, e:{c:1, r:6}}`. ### Column and Row Ranges A column range (spanning every row) is represented with the starting row `0` and the ending row `1048575`: ```js { s: { c: 0, r: 0 }, e: { c: 0, r: 1048575 } } // A:A { s: { c: 1, r: 0 }, e: { c: 2, r: 1048575 } } // B:C ``` A row range (spanning every column) is represented with the starting col `0` and the ending col `16383`: ```js { s: { c: 0, r: 0 }, e: { c: 16383, r: 0 } } // 1:1 { s: { c: 0, r: 1 }, e: { c: 16383, r: 2 } } // 2:3 ``` # Common Spreadsheet Address Styles ## A1-Style A1-style is the default address style in Lotus 1-2-3 and Excel. Columns are specified with letters, counting from `A` to `Z`, then `AA` to `ZZ`, then `AAA`. Some sample values, along with SheetJS column indices, are listed: | Ordinal | A1 Name | SheetJS | |:--------|:--------|--------:| | First | `A` | `0` | | Second | `B` | `1` | | 26th | `Z` | `25` | | 27th | `AA` | `26` | | 702nd | `ZZ` | `701` | | 703rd | `AAA` | `702` | | 16384th | `XFD` | `16383` | Rows are specified with numbers, starting from `1` for the first row. SheetJS APIs that take row indices start from `0` (ECMAScript convention). A cell address is the concatenation of column text and row number. For example, the cell in the third column and fourth row is "C4". A cell range is represented as the top-left cell of the range, followed by `:`, followed by the bottom-right cell of the range. For example, the range `"C2:D4"` includes 6 cells marked with ▒ in the table below:
A | B | C | D | E | |
---|---|---|---|---|---|
1 | |||||
2 | ▒ | ▒ | |||
3 | ▒ | ▒ | |||
4 | ▒ | ▒ | |||
5 |