hyperformula
hyperformula copied to clipboard
addColumns throws an error with AlwaysDense address mapping with empty values
Calling addColumns does not work with the address mapping option AlwaysDense but works with AlwaysSparse. An error is only thrown when using buildEmpty as opposed to using buildFromArray. The test also appears to fail even when inserting columns into an index other than 0 so long as there are empty cell values in the index of the column that is being inserted.
Build Empty
Test with "AlwaysDense" throws an error Test with "AlwaysSparse" succeeds
const engine = HyperFormula.buildEmpty({ chooseAddressMappingPolicy: new AlwaysDense() });
engine.addSheet();
engine.setCellContents({ col: 0, row: 0, sheet: 0 }, 1);
engine.setCellContents({ col: 0, row: 1, sheet: 0 }, 2);
engine.setCellContents({ col: 0, row: 5, sheet: 0 }, 5);
engine.addColumns(0, [0, 1]);
Error:
TypeError: Cannot read properties of undefined (reading 'splice')
❯ DenseStrategy.addColumns node_modules/hyperformula/commonjs/DependencyGraph/AddressMapping/DenseStrategy.js:153:45
❯ AddressMapping.addColumns node_modules/hyperformula/commonjs/DependencyGraph/AddressMapping/AddressMapping.js:278:20
❯ node_modules/hyperformula/commonjs/DependencyGraph/DependencyGraph.js:809:31
❯ EmptyStatistics.measure node_modules/hyperformula/commonjs/statistics/Statistics.js:114:20
❯ DependencyGraph.addColumns node_modules/hyperformula/commonjs/DependencyGraph/DependencyGraph.js:808:18
❯ Operations.doAddColumns node_modules/hyperformula/commonjs/Operations.js:1152:57
❯ Operations.addColumns node_modules/hyperformula/commonjs/Operations.js:315:16
❯ CrudOperations.addColumns node_modules/hyperformula/commonjs/CrudOperations.js:139:23
❯ HyperFormula.addColumns node_modules/hyperformula/commonjs/HyperFormula.js:1577:66
- HyperFormula version: 2.0.0
- Operating System: MacOS M1
When using build from array both address mapping options succeed
const engine = HyperFormula.buildFromArray([[1], [2], [], [], [], [5]], {
chooseAddressMappingPolicy: new AlwaysDense(),
});
engine.addColumns(0, [0, 1]);
Hi @jho14, I am sorry you experienced an issue with HyperFormula. I can confirm it is a bug. Our team will fix it in one of the upcoming releases. Thank you for reporting the issue.
Might be related to #855