Getting formula while reading cell data in OpenPyXL

岁酱吖の 提交于 2020-01-17 07:43:33

问题


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 ).

来源:https://stackoverflow.com/questions/45949630/getting-formula-while-reading-cell-data-in-openpyxl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!