react-spreadsheet icon indicating copy to clipboard operation
react-spreadsheet copied to clipboard

Executing formulas

Open mattgmarcus opened this issue 4 years ago • 3 comments

I just found this library and it looks awesome. I tried out the demo on https://iddan.github.io/react-spreadsheet/ and I'm seeing inconsistent behavior for formulas being executed. For example, I have this filled out: image

In B1 is the int 1. In C1 is also the int 1. In D2 I have =B1+C1 which correctly outputs 2. In D3 I have =B1+D2 which returns an error.

Is this expected behavior or is this a bug in the lib?

I also saw this PR which perhaps is an improvement on formula execution? https://github.com/iddan/react-spreadsheet/pull/101

mattgmarcus avatar Mar 04 '21 21:03 mattgmarcus

Hey @mattgmarcus, your observation is right: the formula execution process in React Spreadsheet is far from perfect. Currently, it is based on an ad-hoc integration with the old library hot-formula-parser. My intention was to replace the implementation with a more sufficient engine. I started working on integrating Hyperformula but there seems to be an unacceptable license conflict with the library that I didn't get my head around yet and it should require some time to integrate it well anyway. I would love to get some help with fixing the current implementation or integrating a formula execution engine that complies with the project license.

iddan avatar Mar 06 '21 15:03 iddan

Some examples I found right off the bat:

  • https://github.com/LesterLyu/fast-formula-parser
  • https://github.com/tmtmtmtm/spreadsheet-engine
  • https://github.com/fabiooshiro/xlsx-calc

iddan avatar Mar 06 '21 15:03 iddan

Hi, Screen Shot 2022-01-12 at 10 58 58 AM

I checked the formula in the following manner (See screenshot for details) and seems to work. In C1 - has a formula - A1 + B1, C2 has a value, and C3 has formula =(C1) + C2 .

yescay avatar Jan 12 '22 05:01 yescay

This is solved with the new release: [email protected]

iddan avatar Apr 22 '23 10:04 iddan