Skip to content

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

Open
@Esmail-Rahmani

Description

@Esmail-Rahmani

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions