Skip to content

Commit 9981e1b

Browse files
committed
Merge branch 'release/2.6.1'
2 parents 50731c7 + e644c17 commit 9981e1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2891
-2849
lines changed

CHANGELOG.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77

88
## [Unreleased]
99

10+
## [2.6.1] - 2023-12-27
11+
12+
### Fixed
13+
14+
- Fixed an issue where operating on ranges of incompatible sizes resulted in a runtime exception. [#1267](https://github.com/handsontable/hyperformula/issues/1267)
15+
- Fixed an issue where the `simpleCellAddressFromString()` method was crashing when called with a non-ASCII character in an unquoted sheet name. [#1312](https://github.com/handsontable/hyperformula/issues/1312)
16+
- Fixed an issue where adding a row to a very large spreadsheet resulted in the `Maximum call stack size exceeded` error. [#1332](https://github.com/handsontable/hyperformula/issues/1332)
17+
- Fixed an issue where using a column-range reference to an empty sheet as a function argument resulted in the `Incorrect array size` error. [#1147](https://github.com/handsontable/hyperformula/issues/1147)
18+
- Fixed an issue where the SUBSTITUTE function wasn't working correctly with regex special characters. [#1289](https://github.com/handsontable/hyperformula/issues/1289)
19+
- Fixed a typo in the JSDoc comment of the `HyperFormula` class. [#1323](https://github.com/handsontable/hyperformula/issues/1323)
20+
1021
## [2.6.0] - 2023-09-19
1122

1223
### Added
@@ -277,7 +288,7 @@ For more information on this release, see:
277288
- **Breaking change**: Changed config options [#747](https://github.com/handsontable/hyperformula/issues/747):
278289

279290
| before | after |
280-
| --------------------- | -------------------- |
291+
|-----------------------|----------------------|
281292
| matrixColumnSeparator | arrayColumnSeparator |
282293
| matrixRowSeparator | arrayRowSeparator |
283294

@@ -286,14 +297,14 @@ For more information on this release, see:
286297
- **Breaking change**: Changed API methods [#747](https://github.com/handsontable/hyperformula/issues/747):
287298

288299
| before | after |
289-
| ------------------ | ----------------- |
300+
|--------------------|-------------------|
290301
| matrixMapping | arrrayMapping |
291302
| isCellPartOfMatrix | isCellPartOfArray |
292303

293304
- **Breaking change**: Changed Exceptions [#747](https://github.com/handsontable/hyperformula/issues/747):
294305

295306
| before | after |
296-
| ---------------------------- | --------------------------- |
307+
|------------------------------|-----------------------------|
297308
| SourceLocationHasMatrixError | SourceLocationHasArrayError |
298309
| TargetLocationHasMatrixError | TargetLocationHasArrayError |
299310

docs/.vuepress/config.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,6 @@ module.exports = {
132132
alias: '/api/events',
133133
collapsable: true,
134134
},
135-
{
136-
title: 'Error Types',
137-
collapsable: true,
138-
children: fs.readdirSync(path.join(__dirname, '../api/classes'))
139-
.filter((n) => n.match(/.*error\.md$/))
140-
.map(f => `/api/classes/${f}`)
141-
},
142135
],
143136
'/': [
144137
{
@@ -178,6 +171,7 @@ module.exports = {
178171
['/guide/integration-with-react', 'Integration with React'],
179172
['/guide/integration-with-vue', 'Integration with Vue'],
180173
['/guide/integration-with-angular', 'Integration with Angular'],
174+
['/guide/integration-with-svelte', 'Integration with Svelte'],
181175
]
182176
},
183177
{

docs/api-template.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,3 @@ hfInstance.on('sheetAdded', handler);
5151

5252
const nameProvided = hfInstance.addSheet('MySheet3');
5353
```
54-
55-
#### Error Types
56-
This page is a list of errors thrown by the HyperFormula instance that may be thrown depending on the method used.
57-
58-
An example of how you can handle an error: adding a sheet which name is already taken:
59-
```javascript
60-
// variable used to carry the message for the user
61-
let messageUsedInUI;
62-
63-
// attempt to add a sheet
64-
try {
65-
hfInstance.addSheet('MySheet1');
66-
67-
// whoops! there is already a sheet named 'MySheet1'
68-
} catch (e) {
69-
70-
// notify the user that a sheet with an ID of 5 does not exist
71-
if (e instanceof SheetNameAlreadyTakenError) {
72-
messageUsedInUI = 'Sheet name already taken';
73-
}
74-
// a generic error message, just in case
75-
else {
76-
messageUsedInUI = 'Something went wrong';
77-
}
78-
}
79-
```

docs/guide/advanced-usage.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ console.log(winningTeam)
122122
## Demo
123123

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

docs/guide/arrays.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Use array formulas to perform an operation (or call a function) on multiple cell
55
## About arrays
66

77
In HyperFormula, an array can be:
8-
* A range of cell addresses (e.g. `A1:A10`)
9-
* A result of an arithmetic operation (e.g. `5*A1:B5`)
10-
* A result of a function (e.g. `=ARRAYFORMULA(ARRAY_CONSTRAIN(A2:E5, 2, 2))`)
11-
* An **inline array**: an ad-hoc array that doesn't refer to any range of cells (e.g. `{1, 3, 5}`)
8+
* A range of cell addresses (e.g., `A1:A10`)
9+
* A result of an arithmetic operation (e.g., `5*A1:B5`)
10+
* A result of a function (e.g., `=ARRAYFORMULA(ARRAY_CONSTRAIN(A2:E5, 2, 2))`)
11+
* An **inline array**: an ad-hoc array that doesn't reference any range of cells (e.g., `{1, 3, 5}`)
1212

1313
An array is inherently a two-dimensional object.
1414

@@ -150,7 +150,7 @@ If your specified output array size is larger or equal to the input array size,
150150
### With the array arithmetic mode enabled
151151

152152
When the [array arithmetic mode](#array-arithmetic-mode) is enabled, and you pass an array to a [scalar](#about-arrays) function, the following rules apply:
153-
* Array dimensions need to be consistent (e.g. every row needs to be of the same length).
153+
* Array dimensions need to be consistent (e.g., every row needs to be of the same length).
154154
* If an input array value is missing (due to a difference in dimensions), the corresponding output array value is `#N/A`.
155155
* If a cell evaluates to an array, the array values are spilled into neighboring cells (unless the neighboring cells are already filled).<br>This behavior doesn't apply to ranges, which return the `#VALUE!` error in this case.
156156
* If one of input array dimensions is `1` (`1`x`n` or `n`x`1`), the array is repeated, to match the output array dimensions.

docs/guide/basic-operations.md

Lines changed: 59 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const sheetsCount = hfInstance.countSheets();
4949

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

276264
```javascript
277265
// track the changes triggered by setting
@@ -365,23 +353,53 @@ if (!isRemovable) {
365353
}
366354
```
367355

368-
## What are the "changes"?
356+
## Changes array
369357

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

374362
```javascript
375-
[{
376-
address: { sheet: 0, col: 0, row: 0 },
377-
newValue: { error: [CellError], value: '#REF!' },
378-
}]
363+
[{
364+
address: { sheet: 0, col: 0, row: 0 },
365+
newValue: { error: [CellError], value: '#REF!' },
366+
}]
379367
```
380368

381369
This gives you information about where the change happened, what the
382370
new value of a cell is, and even what type it is - in this case, an
383-
error. The change shows only those parts where calculations were made;
384-
it will return an empty array if there were none.
371+
error.
372+
373+
The array of changes includes only cells that have different **values** after performing the operation. See the example:
374+
375+
```js
376+
const hf = HyperFormula.buildFromArray([
377+
[0],
378+
[1],
379+
['=SUM(A1:A2)'],
380+
['=COUNTBLANK(A1:A3)'],
381+
]);
382+
383+
// insert an empty row between the row 0 and the row 1
384+
const changes = hf.addRows(0, [1, 1]);
385+
386+
console.log(hf.getSheetSerialized(0));
387+
// sheet after adding the row:
388+
// [
389+
// [0],
390+
// [],
391+
// [1],
392+
// ['=SUM(A1:A3)'],
393+
// ['=COUNTBLANK(A1:A4)'],
394+
// ]
395+
396+
console.log(changes);
397+
// changes include only the COUNTBLANK cell:
398+
// [{
399+
// address: { sheet: 0, row: 4, col: 0 },
400+
// newValue: 1,
401+
// }]
402+
```
385403

386404
## Demo
387405

0 commit comments

Comments
 (0)