I'm trying to parse an excel worksheet using EPPlus, and having issues getting values from formula cells. The document I'm using is downloaded from internet as byte array on runtime, and is working fine if saved and opened using Excel. File format is .xlsm (macros enabled).
The issue is the following:
Some cells contain formulas, that just reference cells in different sheets, like for example:
='diffSheet'!A25
. I cannot get values from such cells: cell.Value
is null, and cell.Text
is just " -".
I tried calling Calculate() method on those cells, but all it makes is just loads for a really long time, and then returns the "#VALUE" error every time.
The weird thing, is that the same document is processed by the same code just fine, if the document was opened by Excel previously. I tried downloading the document manually, opening it in Excel, then uploading it back; and the code had no issues getting values from same cells after that. It may be worth pointing out that Excel does not calculate formula values unless you press the Enable Editing button, but there is no such thing is EPPlus as far as I know. I tried to save & reopen the document programmatically, but it did not work.
I hope somebody could explain what's the issue here, and if there is the way to process the document without user having to open it each time.
Thanks in advance!