hyperformula
hyperformula copied to clipboard
[Bug]: copy+pasting a formula that includes number in exponential format fails with the error "There is no AST with such key in the cache"
Description
Attempting to copy+paste a formula that includes exponential notation (e.g. "=1.25e+5") results in the error:
There is no AST with such key in the cache
code to reproduce:
import HyperFormula from 'hyperformula';
const hf = HyperFormula.buildEmpty({
licenseKey: 'gpl-v3',
});
const sheetName = hf.addSheet('main');
const sheetId = hf.getSheetId(sheetName);
// Arrange data
const tableData = [['100000', '1.25e+5', '=100000', '=1.25e+5']];
hf.setCellContents(
{
row: 0,
col: 0,
sheet: sheetId,
},
tableData
);
// Act - copying the first three columns works fine:
hf.copy({
start: { sheet: sheetId, col: 0, row: 0 },
end: { sheet: sheetId, col: 2, row: 0 },
});
hf.paste({ sheet: sheetId, col: 0, row: 1 });
const row1Values = hf.getRangeValues({
start: { sheet: sheetId, col: 0, row: 1 },
end: { sheet: sheetId, col: 2, row: 1 },
});
console.log({ row1Values }); // as expected, values are: [100000, 125000, 100000]
// Act - copying the last column gives the error:
hf.copy({
start: { sheet: sheetId, col: 3, row: 0 },
end: { sheet: sheetId, col: 3, row: 0 },
});
hf.paste({ sheet: sheetId, col: 3, row: 1 }); // results in: Error: There is no AST with such key in the cache
Video or screenshots
No response
Demo
https://stackblitz.com/edit/js-1prf9j?file=index.js,index.html
HyperFormula version
2.5.0
Your framework
No response
Your environment
Chrome 114
Hi @Andrew-Bx
Thank you for reporting this. We can confirm that exponential numbers are sometimes not handled correctly, so this is a bug.