diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-12-28 18:33:45 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-29 00:58:43 +0100 |
commit | f17874ecd23363221c2ae8da34e1ca006165b924 (patch) | |
tree | cb96a759fd0daa2537ccf21dd99f8b9290539965 /Base/res/js | |
parent | cdf87d22044ccb2b87191d73827bc8f2c6f6a51a (diff) | |
download | serenity-f17874ecd23363221c2ae8da34e1ca006165b924.zip |
Spreadsheet: Add a 'contents' getter/setter to Position
This makes it possible to change the cells' contents programmatically!
Diffstat (limited to 'Base/res/js')
-rw-r--r-- | Base/res/js/Spreadsheet/runtime.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Base/res/js/Spreadsheet/runtime.js b/Base/res/js/Spreadsheet/runtime.js index 5f9cac58f7..688b8b7a04 100644 --- a/Base/res/js/Spreadsheet/runtime.js +++ b/Base/res/js/Spreadsheet/runtime.js @@ -7,6 +7,16 @@ class Position { this.name = `${column}${row}`; } + get contents() { + return this.sheet.get_real_cell_contents(this.name); + } + + set contents(value) { + value = `${value}`; + this.sheet.set_real_cell_contents(this.name, value); + return value; + } + static from_name(name) { let sheet = thisSheet; let obj = sheet.parse_cell_name(name); @@ -678,8 +688,8 @@ here.__documentation = JSON.stringify({ "- `with_row(row)`: Returns a Position with its column being this object's, and its row being the provided the value.\n" + "- `with_column(column)`: Similar to `with_row()`, but changes the column instead.\n" + "- `in_sheet(the_sheet)`: Returns a Position with the same column and row as this one, but with its sheet being `the_sheet`.\n" + - "- `value()`: Returns the value at the position which it represents, in the object's sheet (current sheet by default).\n\n" + - "**NOTE**: Currently only supports single-letter column names", + "- `value()`: Returns the value at the position which it represents, in the object's sheet (current sheet by default).\n" + + "- `contents`: An accessor for the real contents of the cell (i.e. the text as typed in the cell editor)\n", examples: { "here().up().value()": "Get the value of the cell above this one", "here().up().with_column('A')": |