=0.1+0.2 // results in 0.30000000000000004
=(0.1 +0.2) * 43.0 // results in 12.900000000000002
A Worksheet provides a grid of cells for entering and displaying data. Each cell may contain formulas and refer to other cells.
The Worksheet Node uses the Rune language to define formulas and code. The Rune language is similar to Rust. Unlike Rust, Rune doesn't require type annotations, and it is designed to run in a sandboxed environment.
The Worksheet Node supports the following keyboard shortcuts:
The result of a formula is displayed in the cell. The formula is evaluated when the cell is updated.
If the first character is = then it's interpreted as a formula. If it's a single quote ' then it's interpreted as a string. Any other value will attempt to interpret it as a value, e.g. 43.2 will become an f64 and some text will be interpreted as a string.
Below is a basic example of multiplying two numbers:
=23*53
Result: 1219
More complex formulas can be created using variables and functions. For example:
=let a = 23;let b = 53; a*b
Other cells can also be referenced using the cell and cellr functions. For example:
=cell(5, 10) * cellr(-1, -1)
cell - Returns the value of the cell at the specified row, and column.cellr - Returns the value of the cell at the specified row and column relative to the current cell.The worksheet node uses the Rune scripting language for formulas, which means that data types are more strict than traditional spreadsheet formula languages. In general, integers and floating point numbers will not automatically be compatible in mathematical calculations. In these situations and error will be displayed when types are incompatible and require manual intervention.
Numbers without a decimal point are represented as 64 bit integers. Numbers with a decimal point are represented as 64 bit floating point numbers.
The Decimal type is available for calculations requiring improved precision without rounding, such as for financial calculations. Numbers are defined as Decimal using the d(..) function.
=d("0.1")+d("0.2") // results in 0.3
The d(..) function also accepts numeric values
=(d(0.1) + d(0.2)) * d(43) // the d(..) function can convert both floats and integers into Decimal numbers
=0.1+0.2 // results in 0.30000000000000004
=(0.1 +0.2) * 43.0 // results in 12.900000000000002
As a node in the graph, the Worksheet Node can connect to other nodes to receive data. The number of inputs available is configured in the Configuration Panel.
Data in connected upstream nodes can be accessed by a worksheet depending on the channel's data format. RecordBatch, JSON, and raw text are currently supported.
Data from a RecordBatch may be accessed with the input command:
=input(INPUT_ID, CHANNEL_NAME, ADDRESS)
Address can be a single cell, a range, a whole column or a whole row.
=input(0, "Data", column("SepalLengthCm")) - selects the entire SepalLengthCm column from Input 0's Data channel.
These data types currently only support fetching the entire record using input_all
=input_all(INPUT_ID, CHANNEL_NAME)
For example, this will fetch the Plot channel on input 1
=input_all(1, "Plot")
Upstream node data is available to cells depending on what format it's in:
Regardless of the data format, the data can be passed around the worksheet, manipulated to the extent that the data format allows, and passed to downstream nodes.
A Worksheet node can have several outputs. Outputs are configured in the Configuration Panel. Each output provides two channels: a RecordBatch channel, which can generally be used by machine learning nodes, and a JSON channel.
| Command | Example | Description |
|---|---|---|
address(column, row) | =address(1, 2) | Generates an address to a cell a sheet. Generally used with the input command. |
addresses([values]) | =addresses([(1,2), (1,3)]) | Generates a list of addresses to cells in a sheet. Generally used with the input command. |
address_range((a,b), (x,y)) | =address_range((10,10), (20,20)) | Generates a rectangular window of addreses in a sheet. Generally used with the input command. |
column(column) | =column(43) | Selects an entire column. Generally used with the input command. |
d(value) | =d("4.001") | Defines a Decimal number. Decimal numbers are suitable for financial calculations. This implementation uses the Rust Decimal crate. |
json(value) | =json([2,3,4]) | Creates a JSON map |
row(row) | =row(15) | Selects an entire row. Generally used with the input command. |
Note that some functions may return multiple values. In these cases, the results will be an array.
| Command | Example | Description |
|---|---|---|
cell(column, row) | =cell(1, 2) | Retrieves the value from the specified cell address. |
cellr(offset_x, offset_y) | =cellr(-1, 0) | Retrieves the value from the cell relative to the current cell's position. |
input(input_id, channel_name, key) | =input(0, "Data", column("SepalLengthCm")) | Retrieves the data from the specified input channel. Key may be any addressing value, such as column, row, address_range, etc. |
input_all(input_id, channel_name) | =input_all(1, "Plot") | Retrieves the data from the specified input channel. |
Note that these operations work on both static arrays, as well as calculated arrays and data fetched as arrays from input channels.
| Command | Example | Description |
|---|---|---|
sum(values) | =sum([1, 2, 3]) | Adds values together. |
product(values) | =product([1, 2, 3]) | Multiplies values together. |
count(values) | =count([1, 2, 3]) | Counts the number of elements in the list. |
min(values) | =min([1, 2, 3]) | Returns the minimum value in the list. |
max(values) | =max([1, 2, 3]) | Returns the maximum value in the list. |
average(values) | =average([1, 2, 3]) | Provides the average value of the list. |