hyperformula icon indicating copy to clipboard operation
hyperformula copied to clipboard

[Bug]: IF formula error

Open luotaox opened this issue 9 months ago • 3 comments

Description

Description

In Vue3 by setCellContents set=IF(Sheet2!B1>1, “true”, “false”) the following exception is reported Uncaught TypeError: Cannot read properties of undefined (reading ' licenseKeyValidityState') But under Nodejs it works fine

Video or screenshots

Image

Demo

https://stackblitz.com/edit/vitejs-vite-e4bvdm7a?file=src%2FApp.vue

HyperFormula version

v3.0.0

Your framework

Vue3

Your environment

windows edge

luotaox avatar Feb 20 '25 07:02 luotaox

Thank you for sharing the issue result. I was able to replicable the error response, and while we keep executing the same method over and over, we get an additional error

vue.js?v=95fbf505:2334 Uncaught Error: Value of the formula cell is not computed.
    at Proxy.getCellValue (hyperformula.js?v=49c994f8:11765:13)
    at Proxy.getCellValue (hyperformula.js?v=49c994f8:11210:21)
    at Proxy.getScalarValue (hyperformula.js?v=49c994f8:13314:39)
    at Proxy.getCellValue (hyperformula.js?v=49c994f8:21747:59)
    at hyperformula.js?v=49c994f8:21753:57
    at Proxy.genericSheetGetter (hyperformula.js?v=49c994f8:21766:21)
    at Proxy.getSheetValues (hyperformula.js?v=49c994f8:21753:17)
    at hyperformula.js?v=49c994f8:21797:54
    at Proxy.genericAllSheetsGetter (hyperformula.js?v=49c994f8:21789:27)
    at Proxy.getAllSheetsValues (hyperformula.js?v=49c994f8:21797:17)

I haven't been able to identify the reason behind it yet, but as the syntax is correct, I believe we can call it a bug. I will update the thread with any new findings.

AMBudnik avatar Mar 05 '25 10:03 AMBudnik

I think I found the problem, using ref in Vue3 turns it into a responsive object. This operation may affect the original object, the correct operation is to not use or use reactive, if you must use ref you can use toRaw wrapping, this error may not only occur in setting formulas. Maybe you guys can mark the docs This is the demo link https://stackblitz.com/edit/vitejs-vite-mwacnqr2?file=src%2FApp.vue

luotaox avatar Mar 05 '25 12:03 luotaox

Thank you for additional research.

AMBudnik avatar Mar 05 '25 12:03 AMBudnik

I think it's worth mentioning on our Integration with Vue site.

sequba avatar Jul 25 '25 11:07 sequba

In more complex cases, like using HyperFormula together with Handsontable, it also may be helpful to prevent Vue from injecting the reactive proxy by marking the HyperFormula instance as raw:

const hfInstance = markRaw(
  HyperFormula.buildEmpty({
    licenseKey: 'internal-use-in-handsontable',
  })
);

sequba avatar Oct 02 '25 13:10 sequba

Hi @luotaox

I am happy to share the good news. We just launched HyperFormula v3.1.0 and we updated our Integration with Vue guide to describe this issue.

Here, you can read more about the changes in this version.

sequba avatar Oct 15 '25 11:10 sequba