How to copy a cell value instead of a formula from

2019-08-17 05:17发布

I am trying to use a python code to alter a single value in excel sheet and based on that value, certain calculations are being performed on the sheet itself. Finally, I need to read the answer but instead of the value, it is giving me the formula.

import math
import openpyxl
M, Vb = 0, 0
wb = openpyxl.load_workbook(r"calc.xlsx")
data_sheet = wb['Sheet2']
calc_sheet = wb['Sheet1']
Vb = data_sheet.cell(row=2,column=1).value
calc_sheet.cell(row=30,column=4).value = Vb
wb.save(r"calc.xlsx")
M = calc_sheet.cell(row=26,column=4).value
print(M)

it returns P33 rather than the numerical value.

标签: python excel
0条回答
登录 后发表回答