Skip to content

Commit

Permalink
Merge branch 'develop' into feature/issue-960
Browse files Browse the repository at this point in the history
  • Loading branch information
sequba authored Dec 19, 2023
2 parents a694abe + 896d501 commit e92bca9
Show file tree
Hide file tree
Showing 24 changed files with 606 additions and 264 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Fixed an issue where operation on ranges with incompatible sizes resulted in a runtime exception. [#1267](https://github.com/handsontable/hyperformula/issues/1267)
- Fixed an issue where `simpleCellAddressFromString` method was crashing when called with a non-ASCII character in an unquoted sheet name. [#1312](https://github.com/handsontable/hyperformula/issues/1312)
- Fixed a bug where adding a row to the very large spreadsheet resulted in `Maximum call stack size exceeded` error. [#1332](https://github.com/handsontable/hyperformula/issues/1332)
- Fixed a typo in the JSDoc comment of the `HyperFormula` class. [#1323](https://github.com/handsontable/hyperformula/issues/1323)
- Fixed the `Incorrect array size` error when using column range reference to an empty sheet as a function argument. [#1147](https://github.com/handsontable/hyperformula/issues/1147)
- Fixed a bug where function SUBSTITUTE did not work correctly with regexp special characters. [#1289](https://github.com/handsontable/hyperformula/issues/1289)

## [2.6.0] - 2023-09-19

Expand Down
1 change: 1 addition & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ module.exports = {
['/guide/integration-with-vue', 'Integration with Vue 3'],
['/guide/integration-with-vue-2', 'Integration with Vue 2'],
['/guide/integration-with-angular', 'Integration with Angular'],
['/guide/integration-with-svelte', 'Integration with Svelte'],
]
},
{
Expand Down
100 changes: 59 additions & 41 deletions docs/guide/basic-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const sheetsCount = hfInstance.countSheets();

A sheet can be removed by using the `removeSheet` method. To do that
you need to pass a mandatory parameter: the ID of a sheet to be
removed. This method returns a list of cells whose values were affected
by this operation together with their absolute addresses and new values.
removed.
This method returns [an array of changed cells](#changes-array).

```javascript
// track the changes triggered by removing the sheet 0
Expand Down Expand Up @@ -78,9 +78,8 @@ hfInstance.renameSheet(sheetID, 'AnotherNewName');
### Clearing a sheet

A sheet's content can be cleared with the `clearSheet` method. You need
to provide the ID of a sheet whose content you want to clear. This
method returns a list of cells whose values were affected by this
operation together with their absolute addresses and new values.
to provide the ID of a sheet whose content you want to clear.
This method returns [an array of changed cells](#changes-array).

```javascript
// clear the content of sheet 0
Expand All @@ -91,9 +90,8 @@ const changes = hfInstance.clearSheet(0);

Instead of removing and adding the content of a sheet you can replace
it right away. To do so use `setSheetContent`, in which you can pass
the sheet ID and its new values. This method returns a list of cells
whose values were affected by this operation together with their
absolute addresses and new values.
the sheet ID and its new values.
This method returns [an array of changed cells](#changes-array).

```javascript
// set new values for sheet 0
Expand All @@ -107,8 +105,7 @@ const changes = hfInstance.setSheetContent(0, [['50'], ['60']]);
You can add one or more rows by using the `addRows` method. The first
parameter you need to pass is a sheet ID, and the second parameter
represents the position and the size of a block of rows to be added.
This method returns a list of cells whose values were affected by this
operation together with their absolute addresses and new values.
This method returns [an array of changed cells](#changes-array).

```javascript
// track the changes triggered by adding
Expand All @@ -121,9 +118,8 @@ const changes = hfInstance.addRows(0, [0, 2]);
You can remove one or more rows by using the `removeRows` method. The
first parameter you need to pass is a sheet ID, and the second
parameter represents the position and the size of a block of rows to
be removed. This method returns a list of cells whose values were
affected by this operation together with their absolute addresses
and new values.
be removed.
This method returns [an array of changed cells](#changes-array).

```javascript
// track the changes triggered by removing
Expand All @@ -141,8 +137,7 @@ to pass the following parameters:
* Number of rows to be moved
* Target row

This method returns a list of cells whose values were affected by
this operation, together with their absolute addresses and new values.
This method returns [an array of changed cells](#changes-array).

```javascript
// track the changes triggered by moving
Expand All @@ -156,8 +151,7 @@ You can change the order of rows by using the `setRowOrder` method. You need to
* Sheet ID
* New row order

This method returns a list of cells whose values were affected by
this operation, together with their absolute addresses and new values.
This method returns [an array of changed cells](#changes-array).

```javascript
// row 0 and row 2 swap places
Expand All @@ -171,9 +165,8 @@ const changes = hfInstance.setRowOrder(0, [2, 1, 0]);
You can add one or more columns by using the `addColumns` method.
The first parameter you need to pass is a sheet ID, and the second
parameter represents the position and the size of a block of columns
to be added. This method returns a list of cells whose values were
affected by this operation together with their absolute addresses
and new values.
to be added.
This method returns [an array of changed cells](#changes-array).

```javascript
// track the changes triggered by adding
Expand All @@ -186,9 +179,8 @@ const changes = hfInstance.addColumns(0, [0, 2]);
You can remove one or more columns by using the `removeColumns` method.
The first parameter you need to pass is a sheet ID, and the second
parameter represents the position and the size of a block of columns
to be removed. This method returns a list of cells which values were
affected by this operation together with their absolute addresses
and new values.
to be removed.
This method returns [an array of changed cells](#changes-array).

```javascript
// track the changes triggered by removing
Expand All @@ -206,8 +198,7 @@ You need to pass the following parameters:
* Number of columns to be moved
* Target column

This method returns a list of cells whose values were affected by
this operation together with their absolute addresses and new values.
This method returns [an array of changed cells](#changes-array).

```javascript
// track the changes triggered by moving
Expand All @@ -221,8 +212,7 @@ You can change the order of columns by using the `setColumnOrder` method. You ne
* Sheet ID
* New column order

This method returns a list of cells whose values were affected by
this operation, together with their absolute addresses and new values.
This method returns [an array of changed cells](#changes-array).

```javascript
// column 0 and column 2 swap places
Expand Down Expand Up @@ -250,8 +240,7 @@ to pass the following parameters:
* Source range ([SimpleCellRange](../api/interfaces/simplecellrange))
* Top left corner of the destination range ([SimpleCellAddress](../api/interfaces/simplecelladdress))

This method returns a list of cells whose values were affected by
this operation together with their absolute addresses and new values.
This method returns [an array of changed cells](#changes-array).

```javascript
// choose the source cells
Expand All @@ -270,8 +259,7 @@ You can set the content of a block of cells by using the
`setCellContents` method. You need to pass the top left corner address
of a block as a simple cell address, along with the content to be set.
It can be content for either a single cell or a set of cells in an array.
This method returns a list of cells whose values were affected by this
operation together with their absolute addresses and new values.
This method returns [an array of changed cells](#changes-array).

```javascript
// track the changes triggered by setting
Expand Down Expand Up @@ -365,23 +353,53 @@ if (!isRemovable) {
}
```

## What are the "changes"?
## Changes array

Several methods return the "changes". This is a list of cells
whose values were affected by an operation, together with their
absolute addresses and new values.
All data modification methods return an array of `ExportedChange`.
This is a collection of cells whose **values** were affected by an operation,
together with their absolute addresses and new values.

```javascript
[{
address: { sheet: 0, col: 0, row: 0 },
newValue: { error: [CellError], value: '#REF!' },
}]
[{
address: { sheet: 0, col: 0, row: 0 },
newValue: { error: [CellError], value: '#REF!' },
}]
```

This gives you information about where the change happened, what the
new value of a cell is, and even what type it is - in this case, an
error. The change shows only those parts where calculations were made;
it will return an empty array if there were none.
error.

The array of changes includes only cells that have different **values** after performing the operation. See the example:

```js
const hf = HyperFormula.buildFromArray([
[0],
[1],
['=SUM(A1:A2)'],
['=COUNTBLANK(A1:A3)'],
]);

// Insert an empty row between the row 0 and the row 1
const changes = hf.addRows(0, [1, 1]);

console.log(hf.getSheetSerialized(0));
// Sheet after adding the row:
// [
// [0],
// [],
// [1],
// ['=SUM(A1:A3)'],
// ['=COUNTBLANK(A1:A4)'],
// ]

console.log(changes);
// Changes include only the COUNTBLANK cell:
// [{
// address: { sheet: 0, row: 4, col: 0 },
// newValue: 1,
// }]
```

## Demo

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/branding.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ brand materials available on this website are owned by Handsoncode.

* [TMview](https://www.tmdn.org/tmview/#/tmview/detail/EM500000018141121)
(European Trade Mark and Design Network)
* [EUIPO](https://www.euipo.europa.eu/eSearch/#details/trademarks/018141121)
(European Union Intellectual Property Office)
* [EUIPO](https://euipo.europa.eu/eSearch/#details/trademarks/018141121)
(European Union Intellectual Property Office)
15 changes: 7 additions & 8 deletions docs/guide/cell-references.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ different cells in the workbook.

### Referring to named expressions

This is a special case in HyperFormula. Upon creation you define the
This is a special case in HyperFormula. Upon creation, you define the
scope of the expression:

```javascript
Expand Down Expand Up @@ -166,28 +166,27 @@ In HyperFormula, a range is a reference to a group of at least two adjacent cell

### Range definition

Range `<Cell address 1>:<Cell address 2>` is a reference to the smallest possible group of adjacent cells that includes:
Range `<Cell address 1>:<Cell address 2>` is a reference to the smallest rectangular group of adjacent cells that includes:

- The cell at `<Cell address 1>`
- The cell at `<Cell address 2>`
- If referencing across different sheets (so-called 3D reference): all cells on all sheets between `<Cell address 1>` and `<Cell address 2>`

### Range types

HyperFormula features the following types of ranges:

| Range type | Description | Example |
| ------------ | ----------------------------------- | --------------------------------------------- |
|--------------|-------------------------------------|-----------------------------------------------|
| Cell range | Has the shape of a finite rectangle | =A1:B2<br>or =A2:B1<br>or =B1:A2<br>or =B2:A1 |
| Column range | Contains entire columns | =A:B<br>or =B:A |
| Row range | Contains entire rows | =1:2<br>or =2:1 |

### Referencing ranges

You can reference ranges:
- Through relative references (=A1:B2)
- Through absolute references (=A$1:$B$2)
- Across different sheets (=Sheet1!A1:Sheet5!B2)<br>If you don't specify a sheet name for the second cell address, the sheet name of the first cell address is used: `=Sheet5!A1:B2` is equivalent to `=Sheet5!A1:Sheet5!B2`.
- Through a relative reference, e.g. `=A1:B2`
- Through an absolute reference, e.g. `=A$1:$B$2`
- Through a reference with an explicit sheet address, e.g. `=Sheet5!A1:B2`

### Range restraints

Expand Down Expand Up @@ -228,7 +227,7 @@ used in a cell.
Consider the following example:

| Formula in C1 | Action | Result in B1 |
| :------------ | :-------------- | :----------- |
|:--------------|:----------------|:-------------|
| =A1+B1+20 | Delete column A | #REF! |

The #REF! error may also occur in other specific situations:
Expand Down
12 changes: 6 additions & 6 deletions docs/guide/dependency-graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,21 @@ node and avoid duplicating the work during computation.
To get the immediate precedents of a cell or a range (the in-neighbors of the cell node or the range node), use the [`getCellPrecedents()`](../api/classes/hyperformula.html#getcellprecedents) method:

```js
const hfInstance = HyperFormula.buildFromArray( [ ['1', '=A1', '=A1+B1'] ] );
const hfInstance = HyperFormula.buildFromArray([[ '1', '2', '=A1', '=B1+C1' ]]);

hfInstance.getCellPrecedents({ sheet: 0, col: 2, row: 0});
// returns [{ sheet: 0, col: 0, row: 0}, { sheet: 0, col: 1, row: 0}]
hfInstance.getCellPrecedents({ sheet: 0, col: 3, row: 0 });
// returns [{ sheet: 0, col: 1, row: 0 }, { sheet: 0, col: 2, row: 0 }]
```

## Getting the immediate dependents of a cell or a range

To get the immediate dependents of a cell or a range (the out-neighbors of the cell node or the range node), use the [`getCellDependents()`](../api/classes/hyperformula.html#getcelldependents) method:

```js
const hfInstance = HyperFormula.buildFromArray( [ ['1', '=A1', '=A1+B1'] ] );
const hfInstance = HyperFormula.buildFromArray([[ '1', '=A1', '=A1+B1', '=B1+C1' ]])

hfInstance.getCellDependents({ sheet: 0, col: 2, row: 0});
// returns [{ sheet: 0, col: 0, row: 0}, { sheet: 0, col: 1, row: 0}]
hfInstance.getCellDependents({ sheet: 0, col: 0, row: 0 })
// returns [{ sheet: 0, col: 1, row: 0 }, { sheet: 0, col: 2, row: 0 }]
```

## Getting all precedents of a cell or a range
Expand Down
16 changes: 16 additions & 0 deletions docs/guide/integration-with-svelte.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Integration with Svelte

The installation process for applications written in Svelte is the
same as in the case of VanillaJS. You can check the
[client-side installation](client-side-installation.md) section for
more details.

## Demo

<iframe
src="https://codesandbox.io/embed/github/handsontable/hyperformula-demos/tree/2.6.x/svelte-demo?autoresize=1&fontsize=11&hidenavigation=1&theme=light&view=preview"
style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
title="handsontable/hyperformula-demos: react-demo"
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
sandbox="allow-autoplay allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts">
</iframe>
Loading

0 comments on commit e92bca9

Please sign in to comment.