Thank you for the reply Charlie.
Yes, I remember that when I open the .xlsx first time after it was created, Excel showed a green message box proudly stating that the '@' symbols were added to the formula for some reason, which I don't remember, and that it will still work as before, which it obviously didn't.
Ok. I had a look at the xml of the respective sheet after it was created, and then again after I fixed the formula and saved it.
The formula related part have originally looked like this:
<c r="E2" s="1">
<f>IF(D2:D1001="","",VLOOKUP(D2:D1001,Reference_dataset_Measures_code,2,FALSE))</f>
<v/>
</c>
It looks exactly as entered, so it have not been corrupted by the safe.
However, after fixing, it looks like this:
<c r="E2" s="1" t="str" cm="1">
<f t="array" ref="E2:E1001">IF(D2:D1001="","",VLOOKUP(D2:D1001,Reference_dataset_Measures_code[],2,FALSE))</f>
<v/>
</c>
So there's an obvious discrepancy in how the formula looks and how it is actually stored.
The first thing is the addition of the '[]' after the named Table name. I have modified my python script to add it there as well, and it fixed the extra single quotes issue.
But I don't know how to get rid of the '@'s. I guess it may have something to do with the attributes in the <f> element added after the correction.
Any idea how I can add those attributes using the openpyxl?