Openpyxl 1.8.5: Reading the result of a formula typed in a cell using openpyxl
openpyxl support either the formula or the value of the formula. You can select which using the data_only
flag when opening a workbook. However, openpyxl does not and will not calculate the result of a formula. There are libraries out there like pycel which purport to do this.
Cant open cells using openpyxl
Use .value
to get information from a cell. Here is the corrected code:
import openpyxl as xl
wb = xl.load_workbook('transactions.xlsx')
sheet = wb['Sheet1']
cell = sheet.cell(1, 1)
print(cell.value)
Identifying cell in Openpyxl
cell.coordinate
will return the cells address in "A1" style.
cell.row
and cell.column
should give you the addresses you need. Here is what I got from the documentation: https://openpyxl.readthedocs.org/en/latest/api/openpyxl.cell.html?highlight=.row#module-openpyxl.cell.cell
It gives you the list of attributes of a cell
object.
I want to read a cell value, not its formula
According to How to access the real value of a cell using the openpyxl module for python
when loading the workbook you have to set data_only to True: wb = load_workbook("file.xlsx", data_only=True)
Related Topics
Google Search from a Python App
What Is the Point of Setlevel in a Python Logging Handler
Return and Yield in the Same Function
Can Anyone Explain Python's Relative Imports
Upload Image Using Post Form Data in Python-Requests
How to Call Setattr() on the Current Module
How to Generate a List of Consecutive Numbers
What Is Different Between All These Opencv Python Interfaces
Receive and Send Emails in Python
Why Does Python's _Import_ Require Fromlist
Detecting Mouse Clicks in Windows Using Python
Can One Get Hierarchical Graphs from Networkx with Python 3
Unicodedecodeerror: 'Ascii' Codec Can't Decode Byte 0Xe2 in Position 13: Ordinal Not in Range(128)