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

Value of the formula cell is not computed when batching setCellContents #1264

Open
BrianHung opened this issue May 10, 2023 · 1 comment
Open
Labels
Bug Something isn't working Impact: Medium

Comments

@BrianHung
Copy link
Contributor

Description

It seems that replacing cell contents that contain a formula at the same address in the same batch results in a Value of the formula cell is not computed error, since the vertex is created but the value is not yet cached in FormulaCellVertex yet since evaluation is suspended.

public getCellValue(address: SimpleCellAddress): InterpreterValue {
const vertex = this.getCell(address)
if (vertex === undefined) {
return EmptyValue
} else if (vertex instanceof ArrayVertex) {
return vertex.getArrayCellValue(address)
} else {
return vertex.getCellValue()
}
}

A potential fix may be to check and return the EmptyValue singleton.

  public getCellValue(address: SimpleCellAddress): InterpreterValue {
    const vertex = this.getCell(address)

    if (vertex === undefined) {
      return EmptyValue
    } else if (vertex instanceof ArrayVertex) {
      return vertex.getArrayCellValue(address)
+  } else if (vertex instanceof FormulaCellVertex) {
+     return vertex.isComputed() ? vertex.getCellValue() : EmptyValue;
    } else {
      return vertex.getCellValue()
    }
  }
import HyperFormula from "hyperformula";

const hf = HyperFormula.buildFromArray([[1, 2, "=A1+B1"]], {
  licenseKey: "gpl-v3"
});

const sheetName = "Sheet1";
const sheetId = hf.getSheetId(sheetName);

hf.suspendEvaluation();
hf.setCellContents({ sheet: sheetId, row: 0, col: 2 }, "=A1/B2");
hf.setCellContents({ sheet: sheetId, row: 0, col: 2 }, "10");
hf.resumeEvaluation();

Demo

https://codesandbox.io/s/young-butterfly-zdxrvc?file=/src/hyperformulaConfig.js

@BrianHung BrianHung added the Bug Something isn't working label May 10, 2023
@AMBudnik
Copy link
Contributor

Thank you for sharing the issue report @BrianHung

We confirmed the issue and will update you as soon as it gets fixed.

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: Medium
Projects
None yet
Development

No branches or pull requests

3 participants