Reputation: 309
I am writing this code to assign a formula to an specific cell depending on the row. But the problem is that when I try to open the Excel file it throws me an error and delete the formula I wrote.
for z in range(4, 54):
wss.cell(coordinate="J"+str(z), value="=I"+str(z)+"*C"+str(z))
formula = "=SI(ESBLANCO(H"+str(z)+");0;BUSCARV(H"+str(z)+ ";Lista_precios!A3:B"+str(self.ultimaFila+1)+";2;FALSO))"
wss.cell(coordinate="I"+str(z), value=formula)
I am writing the Excel formulas in Spanish because my Excel is in Spanish. The first formula that is simply =I4*C4 works fine. I have printed the variable formula and it is in accordance with Excel but has conflict with Openpyxl
Upvotes: 0
Views: 852
Reputation: 19497
You must write the formula in English and use a comma to separate variables because this is how they are stored in the OOXML file format.
Upvotes: 5