Getting formula while reading cell data in OpenPyX

2019-08-16 09:48发布

I want to update value in excel and get new updated value of output cell in excel using OpenPyXL in python 3

Below is code

import openpyxl
xfile = openpyxl.load_workbook('sheet.xlsx')

sheet = xfile.get_sheet_by_name('Sheet1')
print (sheet['D2'].value)
sheet['A2'] =  3
print (sheet['D2'])
xfile.save('sheet.xlsx')

and below is sample data in excel : Image of excel file

and below is output I am getting

python3 xl.py
=SUM(A2:C2)
<Cell 'Sheet1'.D2>

How can I get value of this cell as calculated after application of formula (=SUM(A2:C2) in this case ).

0条回答
登录 后发表回答