handsontable / handsontable/hyperformula

[Bug]: Consistent Range Handling and Formula Text Access in Custom Function Arguments

Open
#1,465 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.8k
Forks
171
Avg merge
1d 22h
Merged PRs (30d)
7

Description

Description

I'm implementing a custom function(eg. AGGREGATE) in a HyperFormula plugin that needs both the data and the formula text of each argument range to determine if certain functions should be ignored. However, I’m encountering two issues:

  1. Range Undefined for Single Cells: When a single cell is passed as an argument, the range property is undefined. For multi-cell ranges, range provides the expected values. For consistency, it would be helpful if range was defined for single cells as well.

  2. Request for Formula Text: In addition to the data, I need access to the formula text used in each range. Currently, I have no straightforward way to access the formula text directly in the custom function. This would allow me to handle certain behaviors based on the specific formula used.

Here is the code I’m using:

export class MyCustomPlugin extends FunctionPlugin {
  aggregate(ast, state) {
    return this.runFunction(
      ast.args,
      state,
      this.metadata('AGGREGATE'),
      (args) => {
        console.log(args);
      }
    );
  }
}
Expected Behavior
  • The range property should not be undefined for single-cell arguments.
  • Ideally, HyperFormula could provide formula text alongside the data for each argument range, allowing custom functions to process ranges based on the formula used.
Video or screenshots

WhatsApp Image 2024-11-25 at 15 13 43

Demo

https://codesandbox.io/p/devbox/exciting-cloud-cd9j7s

HyperFormula version

2.7.1

Your framework

Vue 3

Your environment

Chrome 90 Macos 15.0.1

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 MyCustomPlugin.aggregate and the FunctionPlugin.runFunction call shown in the issue, using the AGGREGATE metadata path as the entry point. Trace how single-cell and multi-cell arguments are represented and whether formula text is exposed. Done means the requested argument information is consistently available to custom functions and the behavior is covered by the relevant project checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.