Excel doesn't support the shared formulas (created by the OpenXML SDK https://www.microsoft.com/en-us/download/details.aspx?id=30425) as expected:
- formulas having a reference to a sheet and not using absolute references (eg. “=VLOOKUP(A1;Sheet2!A:B;2;0)”)
- formulas using structured references such as [@[Sales Amount]] (https://support.office.com/en-us/article/using-structured-references-with-excel-tables-f5ed2452-2337-4f71-bed3-c8ae6d2b276e)
provoke errors when the file is opened or saved, sometimes with the following error: "one or more formula ... are longer than the allowed limit of 8192 characters"
On the other hand, the following shared formulas work correctly:
- “=VLOOKUP(A1;Sheet2!$A:$B;2;0)” (using absolute references with dollars).
- "=A1" or "=$A1" (when extending the formula across a column)
The XML structure looks like this:
B2: <c r="B2"><f t="shared" ref="B2:B3" si="0">VLOOKUP(A2,Sheet2!A:B,2,0)</f><v></v></c>
B3: <c r="B3"><f t="shared" si="0"></f><v></v></c>
Replace the formula by the one with dollars, it will work. By a structured references, it won't, etc.
When using such formulas through the Excel UI, expanding the formula will either lead to a shared formula or not, depending on whether the formula is supported (I suppose). Trouble is that all formulas should be supported, or else it should be documented somewhere.
When a formula is a shared formula (t value is shared) then this value indicates the group to which this particular cell's formula belongs. The first formula in a group of shared formulas is saved in the f element. This is considered the 'master' formula cell. Subsequent cells sharing this formula need not have the formula written in their f element. Instead, the attribute si value for a particular cell is used to figure what the formula expression should be based on the cell's relative location to the master formula cell.
Reference: https://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.cellformula.aspx
As anyone else experienced this?