jspreadsheet / jspreadsheet/ce

Automatically update when referenced cells change for custom javascript functions

Open
#1,303 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
JavaScript
Stars
7.2k
Forks
890
PR merge metrics
No merged PRs in 30d

Description

I'm experimenting with jexcel and am very impressed so far, one thing that I found very hard to do was to write a jexcel-javascript function like in the footer example. I noticed, that this formula only works in the footer and not in the body of the table. It is not automatically updated, when the values in the column change. (Is this considered a bug?)

I think it would be great to have a helper-function that allows such custom javascript formulas to communicate their dependent cells. (Maybe that already exists? If I add them to instance.jexcel.formulas during the evaluation of the function I have no real way of cleaning them up, when the cell is changed? Or does that happen automatically?)
I resorted to manually filling the instance.jexcel.formulas in my updateTable-Function for now, but that doesn't feel like a good solution.

One way around this, of course, is to write the functions in a way, that they accept cell-ranges, but that doesn't work, if you want to calculate the sum of a whole column when there might be new rows added, because the A3:A-syntax is not supported. (And also is not easily implemented, because the formulas-Array would also need to be updated, so one would have to keep track of all the open ranges that are in the spreadsheet?)

Edit: It would be great, if the getValue and getValueFromCoords would automatically be tracked as a dependency - for example.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the footer example and trace how custom formulas use instance.jexcel.formulas, updateTable, getValue, and getValueFromCoords. Check how referenced cells are currently tracked and cleaned up. Done means a custom function in the body recalculates when values or rows in its referenced range change, with the behavior covered by an appropriate test or example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.