Help with handsontable update (6.2.2 to 9.0.1 + Hyperformula)

Tags: #<Tag:0x00007efc64c70350>

Hello!

I’m updating Handsontable from 6.2.2 to 9.0.1.
Already fix some things, but I’m having some problems to replace some code.

  1. In old formulas plugin it was possible to access the parser by using this code:

    hot.getPlugin('formulas').sheet.parser

    Is there a way of doing it in Hyperformulas?

    Use cases:

    • I want to set a listener for ‘callCellValue’ and ‘callRangeValue’ like this:

      hot.getPlugin('formulas').sheet.parser.on('callCellValue', this.cellContentListener); hot.getPlugin('formulas').sheet.parser.on('callRangeValue', this.cellRangeListener);

    • I want to use parse function, like this:

      const res = hot.getPlugin('formulas').sheet.parser.parse(newValue.split('=')[1].toUpperCase());

      if(res.error === '#VALUE!') { // some code }

  2. In old formulas plugin it was possible to get the number of cells with formula in sheet by using this code:

    hot.getPlugin('Formulas').sheet.matrix.data.length;

    Is there a way of doing it in Hyperformulas?

Thank you for your attention.

Hi @nathalia.pissuti

HyperFormula has a completely different API. Here https://codesandbox.io/s/determined-haslett-n5p6g are the logs for what I hope meets your requirements. But, let me know if you’d like anything more than that.

Hi
I’m going to see this code, if I need any further help I let you know.
Thank you!

@aleksandra_budnik I’m having some difficulties to create custom formulas.

I’m following this example:

https://handsontable.github.io/hyperformula/guide/custom-functions.html#using-a-custom-function

My code is like this:

// Class with custom formula

import { FunctionPlugin } from 'hyperformula';

export class CustomFormulas extends FunctionPlugin {
    hyper(ast, formulaAddress) {
        return 'Hyperformula'.length;
    }
}

CustomFormulas.implementedFunctions = {
    HYPER: {
        method: 'hyper',
    }
};

// File with handsontable instance

import { HyperFormula } from 'hyperformula';
import { CustomFormulas } from './customFormulas.js';

HyperFormula.registerFunctionPlugin(CustomFormulas);

this.hot = new Handsontable(this.container, {
    // ...
    formulas: {
        engine: HyperFormula
    },
    // ...
});

No error is shown in console, but cell with “=HYPER()” show “#NAME?”.

Regular formulas are working fine.

Hi @nathalia.pissuti

within a demo on the page, we also add translation via countHFTranslations.js file Please try to do the same

It was exactly that, sorry, I thought it wasn’t mandatory, because I removed it from demo e it keep working
Thank you for helping me

1 Like