`Value of the formula cell is not computed` when batching setCellContents
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.
https://github.com/handsontable/hyperformula/blob/9f7b2dbfb4096a36e3faca41de7d6f35783029ce/src/DependencyGraph/AddressMapping/AddressMapping.ts#L70-L80
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
Thank you for sharing the issue report @BrianHung
We confirmed the issue and will update you as soon as it gets fixed.