rubyXL icon indicating copy to clipboard operation
rubyXL copied to clipboard

Cells with formulas does not recalculated

Open Pistorius opened this issue 8 years ago • 7 comments

When i change some value in a cell referenced by other with a formula, the result of the value in the cell with the formula does not update. Is this a normal behaviour? Here is the example:

wb= RubyXL::Parser.parse('my_path')
ws= wb[0]

# Value 1
ws[0][0].value
> 5
# Value 2
ws[1][0].value
> 5
# The sum of both with a formula
worksheet[2][0].inspect
> "#<RubyXL::Cell(2,0): \"10\" =A2+A1, datatype=nil, style_index=nil>"
# Changing the value 1
worksheet[0][0].change_contents(55)
> 55
# Cheking the change
ws[0][0].value
> 55
# Cheking the sum
worksheet[2][0].value
> 10

Pistorius avatar Aug 28 '17 14:08 Pistorius

I have exactly the same problem

hugobarthelemy avatar Mar 19 '18 13:03 hugobarthelemy

I am looking for a solution to this also. However, in Excel (on mac) pressing SHIFT+CTRL+ALT+FN+F9 forces rebuilding of dependency tree and does a full recalculation.

VBA solution, which I cannot try without Office subscription, is to put macros into the functions with a Application.Volatile call: https://docs.microsoft.com/en-us/office/vba/api/excel.application.volatile

amaizels-placed avatar Jan 17 '19 00:01 amaizels-placed

@amaizels-placed There's a lot of work that needs to be done to fully support Excel formilas. If you are willing to help, I recommend looking at this branch as references are integral to dealing with formulas.

weshatheleopard avatar Jan 17 '19 00:01 weshatheleopard

This snippet solved the problem for me.

book = RubyXL::Parser.parse(excel_path) book.calc_pr.full_calc_on_load = true

I also started saving the output to a separate file because "Excel does stuff I have no control over"

amaizels-placed avatar Jan 19 '19 00:01 amaizels-placed

This seems to be a duplicate of #94 (which is from 2014 btw...)

sixtyfive avatar Jun 21 '19 13:06 sixtyfive

Can we close this issue?

tracyperangusta avatar Jun 21 '21 07:06 tracyperangusta