1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +00:00

Spreadsheet: Make it possible to refer to ranges in other sheets

Now the range A0:C4 in a sheet named "foo" can be represented as:

    R`sheet("foo"):A0:C4`

This makes it possible to do cross-sheet lookups and more.
This commit is contained in:
Ali Mohammad Pur 2022-06-25 20:05:17 +04:30 committed by Linus Groh
parent 2104e9a6e4
commit 746b8ec8de
4 changed files with 93 additions and 20 deletions

View file

@ -78,6 +78,28 @@ describe("Range", () => {
expect(cellsVisited).toEqual(6);
});
test("multiple sheets", () => {
const workbook = createWorkbook();
const sheet1 = createSheet(workbook, "Sheet 1");
const sheet2 = createSheet(workbook, "Sheet 2");
sheet1.makeCurrent();
sheet1.setCell("A", 0, "0");
sheet1.focusCell("A", 0);
sheet2.setCell("A", 0, "0");
sheet2.setCell("A", 10, "0");
sheet2.setCell("B", 1, "0");
sheet2.focusCell("A", 0);
expect(R).toBeDefined();
let cellsVisited = 0;
R`sheet("Sheet 2"):A0:A10`.forEach(name => {
++cellsVisited;
});
expect(cellsVisited).toEqual(11);
});
test("Ranges", () => {
const workbook = createWorkbook();
const sheet = createSheet(workbook, "Sheet 1");