Skip to content

Bug: Passing data_only=True into from_xls() returns excel formulas instead of cell data values #355

@kartzke

Description

@kartzke

Python version
Python 3.11.6

Package version
python-benedict 0.33.0

Current behavior (bug description)
Using the following code, benedict returns a dictionary with raw cell values, including formulas. Even though the data_only=True kwarg is passed into the constructor.

from benedict import benedict

content = benedict.from_xls("src/data/content.xlsx", sheet="Sheet3", data_only=True)
print(content)

image

Expected behavior
I believe benedict should return the data values instead of formulas. So it should return 'formula': 'A2 value is: abc' instead of 'formula': '="A2 value is: "&A2'.

I'm expecting this because it's an xlsx file, which the docs say uses openpyxl to fetch the data, and I'm passing the data_only=True kwarg into the constructor. If I try to access this data directly in openpyxl, it correctly returns the data values.

If I'm misunderstanding something about the way this is supposed to work, please let me know. :)

from openpyxl import open

wb = open("src/data/content.xlsx", data_only=True)
for i in wb['Sheet3'].values:
    print(i)

image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions