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

Implement shared and array formulas #647

Merged
merged 1 commit into from
Aug 13, 2022
Merged

Conversation

tfussell
Copy link
Owner

@tfussell tfussell commented Aug 13, 2022

Currently cells with formulas like <f t="array" ref="G1:G3">PI()</f> or <f t="shared" ref="F2:F4" si="0">1+1</f> will be lost during parsing. This PR adds partial support for these formula types. Based on this StackOverflow question it's not feasible to write documents using shared formulas as there are Excel-specific details. The best approach therefore is to convert shared formulas into normal formulas during parsing. Unfortunately, this means that the file won't be identical if it is read and then written, but it's better than losing the formulas entirely.

Array formulas should be able to be supported fully but will require some storage in the worksheet and an interface for adding/reading/deleting them. For now they are also converted into normal formulas.

Addresses #639 and #436.

@SimonSchroeder
Copy link

This is a huge step forward for our use case as xlnt does not throw an exception (like with v1.5.0) anymore in our shared formulas when opening the Excel file.

However, our formulas reference other cells. I am not entirely sure of the syntax, but taking your example from above with small modifications, f< t="shared" ref="B1:B3" si="0">A1</f> still does not work as expected. Loading and saving an Excel file will write the formula A1 into all three cells. The expected behavior from Excel is that we write A1 into B1, A2 into B2 and A3 into B3.

I have one software where we either read or write from/to Excel files and never both. So, I am going to use the current version for this software. Other software that modifies Excel files unfortunately destroys the original data. So, I am going to stick to v1.5.0 in that software.

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

Successfully merging this pull request may close these issues.

2 participants