Skip to content

Calculation of cell references as in excel #887

Closed

Description

@doczoidberg

Hi,
is it possible to do an automatic cell reference calculation or calculation as in excel when dropping down the + at the down right (in combination with handsontable)?

image

Activity

  1. added
    Question
    on Jan 20, 2022
  2. bardek8 commented on Jan 21, 2022

    @bardek8
    Contributor

    If I'm not mistaken, this might be achieved in HyperFormula in two ways:
    a) by copying the formula to all the cells below,
    b) by filling the range using the getFillRangeData method.

    I know this might be counter-intuitive at first glance, but both the methods work as we operate on relative addresses underneath :)

  3. doczoidberg commented on Jan 21, 2022

    @doczoidberg
    Author

    @bardek8 thank you. It seems to work with getFillRangeData with Cell references.

    Does this also work with e.g. numbers?
    1,2,3 =>
    1,2,3,4,5
    ?
    It results to 1,2,3,1,2 for me.
    If HF has no implementation for this, can you name me approach what can I do to implement such a logic?

  4. bardek8 commented on Jan 21, 2022

    @bardek8
    Contributor

    Great to hear that it worked!

    No, currently HF has no mechanism for detecting the integer sequences and 1,2,3,1,2 is the intended behavior for now.
    We did try a bit to understand the logic here, but it turns out to be very complicated. For example we can have:

    1,3,2...
    "day 1", "day 2", ...
    "Monday", "Tuesday", ...
    "1 a 1", "2 a 2", ...
    

    For the arithmetic progressions from your example, in order to obtain the new element of the sequence you can add the difference between last two numbers to the last number.

  5. doczoidberg commented on Jan 21, 2022

    @doczoidberg
    Author

    seems to be some string manipulation and excel's TREND function (which is not supported in hf)

    https://superuser.com/questions/1334032/what-exactly-is-excels-auto-fill-algorithm

  6. warpech commented on Feb 10, 2022

    @warpech
    Member

    What works: The problem in topic, as it is already used in Handsontable (see example: https://jsfiddle.net/t69xfk0z/, see source: https://github.com/handsontable/handsontable/blob/cf14362f963befe2d7ecbbda733e721a300b4bb2/handsontable/src/plugins/formulas/formulas.js#L607)

    What doesn't work:

    1. there is no guide in the docs about getFillRangeData, only a short API reference and a mention in two blog posts: https://handsontable.com/blog/articles/2021/10/whats-new-in-hyperformula-1.3.0, https://handsontable.com/blog/articles/2021/7/hyperformula-1-0-0-has-landed. A guide is needed.
    2. a potential new feature about making the sequence detection smarter.
  7. doczoidberg commented on Feb 10, 2022

    @doczoidberg
    Author

    @warpech the example shows the calculation of cell references. This works, yes. But it does not extrapolate numbers and numbers in strings yet

  8. warpech commented on Feb 14, 2022

    @warpech
    Member

    @doczoidberg we will follow this idea for HyperFormula in the new issue #903.

    Please keep in mind that HyperFormula is a library. If your intention is that this would be a nice feature in Handsontable formula plugin, I would be grateful for writing a feature request in Discussions: https://github.com/handsontable/handsontable/discussions/categories/ideas

    On a side note, developers who integrate Handsontable in their apps can use beforeAutofill to implement custom autofill behaviour: handsontable/handsontable#133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions