-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Bug]: Consistent Range Handling and Formula Text Access in Custom Function Arguments #1465
Comments
Hi @Esmail-Rahmani, thank you for reaching out! Unfortunately, I'm unable to access the demo you provided. Please make sure the link is valid. Consider using https://stackblitz.com/, as recently I've found it working more reliably.
I agree; it would make more sense. Please provide a working demo and a code example of the expected behavior. We'll consider implementing this feature.
Custom functions can access many helpers yet to be described in our documentation. To read the formula in the cell provided as an argument, you can use Serialization.getCellFormula or Serialization.getCellSerialized method. E.g.: export class MyCustomPlugin extends FunctionPlugin {
aggregate(ast, state) {
return this.runFunction(
ast.args,
state,
this.metadata('AGGREGATE'),
(args) => {
ast.args.forEach((arg) => {
const relativeAddr = arg.reference;
const absoluteAddr = relativeAddr.toSimpleCellAddress(state.formulaAddress);
const cellFormula = this.serialization.getCellSerialized(absoluteAddr);
console.log(cellFormula);
});
}
);
}
} |
Hi dear @sequba, As you can see, no argument for the args has the reference property, therefore, the relativeAddr is undefined. I would really appreciate to have your comment. NOTE: Here is the format of the aggregate function: AGGREGATE(function_num, options, ref1, [ref2], …) |
@JKhaledJ, please provide a working demo on https://stackblitz.com/. Then I could analyze the issue. |
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:
Range Undefined for Single Cells: When a single cell is passed as an argument, the
range
property isundefined
. For multi-cell ranges,range
provides the expected values. For consistency, it would be helpful ifrange
was defined for single cells as well.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:
Expected Behavior
range
property should not beundefined
for single-cell arguments.Video or screenshots
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
The text was updated successfully, but these errors were encountered: