tfussell / xlnt

:bar_chart: Cross-platform user-friendly xlsx library for C++11+
Other
1.47k stars 409 forks source link

Shared formulas not being reflected #639

Closed Curttree closed 2 years ago

Curttree commented 2 years ago

When working with a spreadsheet where cells with formulas have been filled with the 'click and drag' method described in #436 it appears that any cell which has been filled in this manner does not properly reflect the presence of a formula. While the parsing error seems to be resolved, the actual content that was populated by this method does not seem to be handled as expected.

This would make sense, as the actual formula isn't stored with the rest of the cell information ex. `

44568

`

but instead stored with the initial cell that the formula was sourced from ex. `

A2+1 44564

`

At the time of raising this issue, it appears that A3 would return true when calling xlnt::cell::has_formula() whereas cells A4:A:12 would return false.

It would be great if cells within the given range would properly reflect the presence of a formula when xlnt::cell::has_formula() is called. Ideally, xlnt::cell::formula() would also return the actual formula that is reflected within Excel, though I recognize that is a bigger task due to how the cell information is stored.

I'm attaching a basic example XLSX file which was used to source the above examples.

referencedFormula.xlsx

tfussell commented 2 years ago

I've implemented shared formula support in https://github.com/tfussell/xlnt/pull/647. If you read a file with shared formulas, you should see them as normal formulas on cells when calling "cell.formula()".