问题描述
我有一个Excel 2010文件,其中包含带有公式的单元格(请参见下面的C2). (下面的屏幕截图1)
I have a excel 2010 file which has cells (See C2 below in formula bar) with formulae. (Screenshot 1 below)
我正在使用python读取值,它正在打印公式,而不是单元格的实际值(eclipse控制台下方的屏幕截图.)
I am reading the value using python and it's printing the formula instead of actual value of the cell (Screenshot below of eclipse console.)
我希望结果打印10.188.11.184,这是由excel单元格的公式填充的值.如何做到这一点?预先感谢.
I want the results to print 10.188.11.184 which is the value populated by the formula of the excel cell. How can this be achieved? Thanks in advance.
推荐答案
来自: https://openpyxl.readthedocs.org/en/latest /usage.html#read-an-existing-workbook
data_only控制具有公式的单元格是否具有公式(默认值)或Excel上次读取工作表时存储的值.
data_only controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet.
wb = load_workbook('file.xlsx', data_only=True)
这篇关于Python仅从Excel单元格读取公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!