Cell Range
Cell ranges can be used to select a subset of cells in a 2D data structure, such as a Sheet
. The syntax for cell ranges follows conventions from spreadsheet-software. Rows are referenced by one-based indices and columns by capitalized characters, ordered alphabetically.
A | B | C | |
1 | Cell A1 | Cell B1 | Cell C1 |
2 | Cell A2 | Cell B2 | Cell C2 |
3 | Cell A3 | Cell B3 | Cell C3 |
Cell ranges can be expressed as whole rows using the row
keyword, whole columns using the column
keyword and custom ranges using the range
keyword.
Selecting Custom Ranges
Using the range
keyword, custom ranges can be selected. Ranges must define a start cell and end cell with the syntax range <start-cell>:<end-cell>
. All cells between these cells are part of the range as if a user had selected the start cell in a spreadsheet-software and dragged the mouse until the end cell. For example range A1:B2
is a range over four cells, from cell A1
to B2
.
Instead of a specific character or integer, the placeholder *
denotes the last available cell in the row or column. For example: A*
is the last cell in column A
and *2
is the last cell in row 2
.
Examples
The following CellRangeSelector
block will select the four cells in the top left corner of a Sheet
:
block ExampleDataSelector oftype CellRangeSelector {
select: range A1:B2;
}
A | B | C | |
1 | Cell A1 | Cell B1 | Cell C1 |
2 | Cell A2 | Cell B2 | Cell C2 |
3 | Cell A3 | Cell B3 | Cell C3 |
The following CellRangeSelector
block will select cells from the first to the last cell in row 2 in a Sheet
:
block ExampleDataSelector oftype CellRangeSelector {
select: range A2:*2;
}
A | B | C | |
1 | Cell A1 | Cell B1 | Cell C1 |
2 | Cell A2 | Cell B2 | Cell C2 |
3 | Cell A3 | Cell B3 | Cell C3 |
The following CellRangeSelector
block will select cells from the top-left most cell to the last cell in column B in a Sheet
:
block ExampleDataSelector oftype CellRangeSelector {
select: range A1:B*;
}
A | B | C | |
1 | Cell A1 | Cell B1 | Cell C1 |
2 | Cell A2 | Cell B2 | Cell C2 |
3 | Cell A3 | Cell B3 | Cell C3 |
Selecting Rows
Using the row
keyword, individual rows can be selected. For example, row 2
will select the second row in a Sheet
. By adding multiple rows to a Collection<CellRange>
, multiple rows can be selected.
Examples
The following RowDeleter
block will delete the first two rows of a Sheet
:
block ExampleRowDeleter oftype RowDeleter {
delete: [row 1, row 2];
}
A | B | C | |
1 | Cell A1 | Cell B1 | Cell C1 |
2 | Cell A2 | Cell B2 | Cell C2 |
3 | Cell A3 | Cell B3 | Cell C3 |
Selecting Columns
Using the column
keyword, individual columns can be selected. For example, column 2
will select the second column in a Sheet
. By adding multiple columns to a Collection<CellRange>
, multiple columns can be selected.
Examples
The following ColumnDeleter
block will delete the first two columns of a Sheet
:
block ExampleColumnDeleter oftype ColumnDeleter {
delete: [column A, column B];
}
A | B | C | |
1 | Cell A1 | Cell B1 | Cell C1 |
2 | Cell A2 | Cell B2 | Cell C2 |
3 | Cell A3 | Cell B3 | Cell C3 |