[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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM