What algorithm does Excel use to recalculate formulas?

前端 未结 3 1928
萌比男神i
萌比男神i 2021-01-15 16:08

Are the formulas represented in a syntax tree then recalculated using a design pattern like the Visitor pattern? How would you go about reproducing the recalculation process

3条回答
  •  清歌不尽
    2021-01-15 16:45

    Probably, as you say, one guess is that Excel creates a bunch of ASTs, one for each indipendent group of cells, where the leaves are the originating, static data, and the nodes are formulas.

    Then it calculates the result for each node, with a post-order tree traversal algorithm.

    You have to take into account leaf/node cancellation, partial recalculation, ecc. If I'm not wrong, I read somewhere that Excel could benefit of multicore processors to recalculate a sheet in parallel.

提交回复
热议问题