[python][openpyxl]读取excel中公式的结果值

要读取cell中的值,但是,如果cell中的值是一个公式,则读取出来的是公式。有时候我们希望读取到公式计算出来的结果,可以使用load_workbook()中的data_only属性。

load_workbook()中涉及到的全部属性,其中,read_only用于打开一个大空间的xlsx文件(否则会产生MemoryError问题——内存爆了),data_only用于读取cell中的值(如果cell中的值是公式,则会返回计算得到的值)

filename (string or a file-like object open in binary mode c.f., zipfile.ZipFile) – the path to open or a file-like object
read_only (bool) – optimised for reading, content cannot be edited
keep_vba (bool) – preseve vba content (this does NOT mean you can use it)
guess_types (bool) – guess cell content type and do not read it from the file
data_only (bool) – controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet
keep_links (bool) – whether links to external workbooks should be preserved. The default is True
View Code

原文链接:https://blog.csdn.net/tankloverainbow/article/details/80872901

原文地址:https://www.cnblogs.com/rumba/p/12769322.html