Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not giving proper calculate values #225

Closed
peesusanthosh opened this issue May 17, 2018 · 4 comments
Closed

Not giving proper calculate values #225

peesusanthosh opened this issue May 17, 2018 · 4 comments

Comments

@peesusanthosh
Copy link

Description
I am able to insert new values into specified cells and able to fetch the values from a specified cell. In my excel sheet, few cells have formulas in it, so depending on my input the cell which has the formula should return the calculated value. But here the excel is able to take my values as input and store it in excel sheet but it is not giving the calculated values of new entries, it is always giving the calculated values of old entries.

For example, I have manually give 2,3,4 values in B2, B3, B4 cells respectively and B5 has the formula to add them. expected output is a sum of these cells i.e, 9. When I programmatically try to fetch the value of B5 then I am able to get the correct output as 9. Now I am trying to insert the values programmatically to B2, B3, B4 and tried to get the output from B5. At this point, I am able to save new values to B2, B3, B4 as 5,6,7 but B5 is still giving me 9 instead of 18.

Steps to reproduce the issue:

  1. xlsx.SetCellValue("Sheet1", "B5", 10) (for setting the value to cell)
    2.xlsx2.GetCellValue("Sheet1", "B16") (for getting the value of a cell)

Describe the results you received:

Describe the results you expected:

Output of go version:

(paste your output here)

Excelize version or commit ID:

(paste here)

Environment details (OS, Microsoft Excel™ version, physical, etc.):
Windows 10, Microsoft Excel version 1804

@xuri
Copy link
Member

xuri commented May 22, 2018

Thanks for your issue. Excel application will autosave computed value of formula, and we can't get the computed value by the Excelize currently, because this library doesn't implement the formula calculation engine. Reference issue #65, #157 and #198.

@meetmauro
Copy link

There is also a slightly different workflow that is not working and I don't know of any sensible workaround:
if I have an Excel with some formulas already in it and I add only the numbers then when I open Excel I don't see the formulas computed with the actual value I input.
Even if I click on "Calculate now" or "Calculate sheet" in Excel this does not recompute the formulas and the only bad workaround I found to-date is to edit the formula and place the exact same formula (so F2+ENTER). This actually recomputes it but it's not clear why Excel does not recompute them even if I do a "Calculate now" or "Calculate sheet".
Does anybody have a workaround on this?

@xuri
Copy link
Member

xuri commented Jun 13, 2018

Try call the function UpdateLinkedValue() before save the file.

@meetmauro
Copy link

Wow great! This is indeed the case. Working like charm.
Thank you very much for this!

@xuri xuri closed this as completed Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants