gpt4 book ai didi

python - openpyxl.load_workbook(file, data_only=True 不起作用?

转载 作者:行者123 更新时间:2023-11-28 22:38:19 24 4
gpt4 key购买 nike

为什么 x = "None"而不是 "500"?我已经尝试了我所知道的一切并搜索了 1 小时的答案......感谢您的帮助!

import openpyxl

wb = openpyxl.Workbook()
sheet = wb.active
sheet["A1"] = 200
sheet["A2"] = 300
sheet["A3"] = "=SUM(A1+A2)"

wb.save("writeFormula.xlsx")

wbFormulas = openpyxl.load_workbook("writeFormula.xlsx")
sheet = wbFormulas.active
print(sheet["A3"].value)

wbDataOnly = openpyxl.load_workbook("writeFormula.xlsx", data_only=True)
sheet = wbDataOnly.active
x = (sheet["A3"].value)
print(x) # None? Should print 500?

最佳答案

来自documentation

openpyxl never evaluates formula

关于python - openpyxl.load_workbook(file, data_only=True 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35681902/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com