Open milcs opened 9 years ago
Can you provide me with a sample worksheet?
Download a demo perl script with sample excel file from http://stubljar.com/repository/Shared-formulas-not-parsed-example.7z When run, it will use example.xlsx to clone it into result.xlsx.
Unfortunately, as far as I can tell, supporting shared formulas will require a full formula parser in order to determine what the actual modified formula is in each cell, which is not something that I have current plans to do. I'd be willing to look over pull requests for this, but it's likely to be a quite large project.
Luckily I found a great approach creating formulas in my templates preventing excel optimisation into shared formulas.
Environment: perl: v5.20.1 built for MSWin32-x86-multi-thread-64int Spreadsheet::ParseXLSX is up to date (0.16). XML::Twig is up to date (3.48). Spreadsheet::ParseExcel is up to date (0.65).
When crating an excel using copy paste formula, excel will create a shared formula. Using Spreadsheet::ParseXLSX to parse such excel, results in:
Inspecting the XLSX source xml files and looking at the ParseXLSX.pm, the Formula is parsed from the text of the
<f>
tag.The source data of the
<c>
tags with share formula example:<c r="H13" s="31" t="str">
<f t="shared" ref="H13:H27" si="0">IF(ISNUMBER(G13/D13),G13/D13,"NaN")</f>
<v>NaN</v>
</c>
In this example, the formula was copied from H13 to H14..H27. The data for H14..H27 is:<c r="H14" s="36" t="str">
<f t="shared" si="0"/>
<v>NaN</v>
</c>
Cell H14 is just referencing the shared formula. The Spreadsheet::ParseXLSX failed to cope with that.