Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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" #1288

Open
Andrew-Bx opened this issue Jun 21, 2023 · 1 comment
Labels
Bug Something isn't working Impact: High

Comments

@Andrew-Bx
Copy link

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

@adrianszymanski89
Copy link
Contributor

Hi @Andrew-Bx

Thank you for reporting this. We can confirm that exponential numbers are sometimes not handled correctly, so this is a bug.

@adrianszymanski89 adrianszymanski89 added the Bug Something isn't working label Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Impact: High
Projects
None yet
Development

No branches or pull requests

3 participants