feat: Add support for reading shared formulas in XLSX files by ongdisheng · Pull Request #693 · apache/fesod
Purpose of the pull request
This PR adds support for reading shared formulas from XLSX files. Currently, when there are shared formulas in the file, Fesod cannot read the formula text from reference cells. This results in missing formula information for users who need to extract formulas from their Excel data.
What's changed?
This PR implements shared formula support by leveraging Apache POI's formula conversion utilities. When parsing XLSX files, the code now detects shared formulas by checking for the shared type attribute and shared index attribute in the formula XML tags. For master cells that contain the actual formula text, the formula and its position are stored in a map. For reference cells that only contain a shared index, the code retrieves the master formula and converts it to the cell-specific formula by calculating row and column offsets using Apache POI's SharedFormula conversion method. A comprehensive unit test with various formula types has been added to verify the functionality, following the test cases referenced in PR #581.
Current test file: shared_formula.xlsx
Checklist
- I have read the Contributor Guide.
- I have written the necessary doc or comment.
- I have added the necessary unit tests and all cases have passed.