-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Calculating shared formula #300
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
Conversation
-- type and _value is wrong too
… to the formula is shared from
Hi @muscapades - I see where you're going with this branch but I have some concerns:
Right now, my vote is tending towards your previous PR - what are your thoughts? |
Hi @guyonroche, All good points... Ad 1) I don't think the information is lost, since model.sharedFormula still points to the cell where the formula was shared from. So as the branch is now, I think the user has all the information - that the formula was shared, where it was shared from, and what (I think) the formula converts to. This is one reason why I kept the SharedFormulaValue in the branch instead of making the cell a FormulaValue (and loosing the information about where the original formula is). Ad 3) Do you plan to add features like this? Making shared formulas a "first class citizen" in exceljs? Ad 4) Quite right, there may be examples where we need to parse the formula instead of regexing. My inclination would be to wait for those examples to surface before worrying about them. Is there another place in the code where exceljs are handling parsed formulas, and where the conversion could be cleaner? What I did not like about the first PR is that it left the problem to the user of exceljs, and leaving it to everybody to come up with their own handling of it. As a user of exceljs, I would welcome any help it could give me in handling shared formulas. So as a minimum I would propose that SharedFormula.slideFormula is offered to the users as a way out. |
Yeah I intended to make shared formulas first class citizens - with a value of the form { sharedFormula: 'A2', result: 5 } |
That's convenient for constructing excel sheets in exceljs, I can see that. My current use case is to read and analyze excel files, constructed in Excel, and I need to know the formula in each cell, same as what Excel would show when the cell is selected, so I need the converted formula. I don't know what everybody else will be using exceljs for, but for me this is a key feature. The idea behind making two separate branches was precisely to leave it to you to decide what the right way for exceljs to handle shared formulas is. Knowing what the shared formula translates to for a particular cell is useful to me, and I think it might be for others too. |
Cool - I can see the value of that use-case, what we could do is add something like a 'translatedFormula' property on the cell that will run that transformation (lazy style) but still keep the shared link as primary data. |
Hey @muscapades - I'm nearing publish on the other branch. I took the translation formula from this branch and added a convenience function on Cell to return either the real formula or the translated one. |
Further on #298, and builds on #297
It now calculates the formula as it would be when "copied" to this cell.