* Returns source data by passed range. * * @param {object} [start] Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects). * @param {object} [end] Object with physical `row` and `col` keys (or visual column index, if data type is an array of
(
start: {row?: number, col?: number} | null = null, end: {row?: number, col?: number} | null = null, toArray = false
)
| 340 | * @returns {Array} |
| 341 | */ |
| 342 | getByRange( |
| 343 | start: {row?: number, col?: number} | null = null, end: {row?: number, col?: number} | null = null, toArray = false |
| 344 | ) { |
| 345 | let getAllProps = false; |
| 346 | let startRow = null; |
| 347 | let startCol = null; |
| 348 | let endRow = null; |
| 349 | let endCol = null; |
| 350 | |
| 351 | if (start === null || end === null) { |
| 352 | getAllProps = true; |
| 353 | startRow = 0; |
| 354 | endRow = this.countRows() - 1; |
| 355 | |
| 356 | } else { |
| 357 | startRow = Math.min(start.row!, end.row!); |
| 358 | startCol = Math.min(start.col!, end.col!); |
| 359 | endRow = Math.max(start.row!, end.row!); |
| 360 | endCol = Math.max(start.col!, end.col!); |
| 361 | } |
| 362 | |
| 363 | const result: unknown[] = []; |
| 364 | |
| 365 | rangeEach(startRow, endRow, (currentRow: number) => { |
| 366 | result.push(( |
| 367 | getAllProps ? |
| 368 | this.getAtRow(currentRow, undefined, undefined, toArray) : |
| 369 | this.getAtRow(currentRow, startCol!, endCol!, toArray) |
| 370 | )); |
| 371 | }); |
| 372 | |
| 373 | return result; |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * Returns single value from the data array (intended for clipboard copy to an external application). |