hyperformula icon indicating copy to clipboard operation
hyperformula copied to clipboard

[Bug]: In a specific combination of adding rows, content, and column amount alteration we get `Uncaught Error` from the `DenseStrategy`

Open AMBudnik opened this issue 1 year ago • 3 comments

Description

In a specific combination of adding rows, content, and column amount alteration we get Uncaught Error from the DenseStrategy.

Case 1

  • add an empty row below the last one (call addRows() on last index)
  • again, add an empty row below the last one (call addRows() on last index)
  • add a value in the last row (call setCellContents() on the index of the lastly added row)
  • add a new column (call addColumns() on any index)

Case 2

  • add an empty row below the last one (call addRows() on last index)
  • again, add an empty row below the last one (call addRows() on last index)
  • add a value in the last row (call setCellContents() on the index of the lastly added row)
  • remove any column (call removeColumns () on any index),

Video or screenshots

Error for column addition

Uncaught TypeError: Cannot read properties of undefined (reading 'splice')
    at DenseStrategy.addColumns (hyperformula.js?v=bfc9e82e:14088:23)
    at AddressMapping.addColumns (hyperformula.js?v=bfc9e82e:11312:18)
    at hyperformula.js?v=bfc9e82e:13184:27
    at EmptyStatistics.measure (hyperformula.js?v=bfc9e82e:10956:20)
    at _DependencyGraph.addColumns (hyperformula.js?v=bfc9e82e:13183:16)
    at Operations.doAddColumns (hyperformula.js?v=bfc9e82e:18737:30)
    at Operations.addColumns (hyperformula.js?v=bfc9e82e:18183:12)
    at CrudOperations.addColumns (hyperformula.js?v=bfc9e82e:19594:21)
    at _HyperFormula.addColumns (hyperformula.js?v=bfc9e82e:23494:26)
    at main.js:45:4

Error for column removal

Uncaught TypeError: Cannot read properties of undefined (reading 'splice')
    at DenseStrategy.removeColumns (hyperformula.js?v=dabf68a5:14100:23)
    at AddressMapping.removeColumns (hyperformula.js?v=dabf68a5:11319:18)
    at hyperformula.js?v=dabf68a5:13147:27
    at EmptyStatistics.measure (hyperformula.js?v=dabf68a5:10956:20)
    at _DependencyGraph.removeColumns (hyperformula.js?v=dabf68a5:13146:16)
    at Operations.doRemoveColumns (hyperformula.js?v=dabf68a5:18678:30)
    at Operations.removeColumns (hyperformula.js?v=dabf68a5:18189:35)
    at CrudOperations.removeColumns (hyperformula.js?v=dabf68a5:19602:45)
    at _HyperFormula.removeColumns (hyperformula.js?v=dabf68a5:23567:26)
    at main.js:45:4

Demo

{column addition} https://stackblitz.com/edit/vitejs-vite-w55sez?file=index.html,main.js&terminal=dev ; {column removal} https://stackblitz.com/edit/vitejs-vite-1ssmt8?file=index.html,main.js&terminal=dev

HyperFormula version

2.7.0

Your framework

Vanilla JS

Your environment

Chrome 123, macOS Ventura

AMBudnik avatar Apr 12 '24 09:04 AMBudnik

Once it's fixed in the HperFormula, we should verify if the analogous scenario is working correctly in Handsontable

sequba avatar Apr 16 '24 07:04 sequba

i also have this error as the following simple case: let data=[ [], [,1], [,2], [,'=sum(B2:B3)'] ] const options = {licenseKey: 'gpl-v3',} let hf=HyperFormula.buildEmpty(options) hf.addSheet('sheet1') hf.setSheetContent(0,data) let can=hf.isItPossibleToRemoveColumns(0,[0,1]) console.log(can) let changes=hf.removeColumns(0,[0,1]) //throw exception

it's ok to call HyperFormula.buildFromSheets(xxx)

richcanvas avatar Apr 28 '24 06:04 richcanvas

Thank you for sharing the scenario, @richcanvas we will test it as well and update you upon fix.

AMBudnik avatar Apr 29 '24 10:04 AMBudnik

The issue is no longer replicable using Hyperformula v2.7.1. Updated demo: https://stackblitz.com/edit/vitejs-vite-ztmnby?file=index.html,package.json&terminal=dev

@richcanvas Please also check it on your side

AMBudnik avatar Jul 18 '24 11:07 AMBudnik