dgorissen / pycel

A library for compiling excel spreadsheets to python code & visualizing them as a graph
GNU General Public License v3.0
565 stars 147 forks source link

AttributeError: 'Worksheet' object has no attribute 'formula_attributes' #129

Closed karolinabirecka closed 3 years ago

karolinabirecka commented 3 years ago

What actually happened

While running ExcelCompiler(filename=temp_file_name), I got the following error: [ERROR] AttributeError: 'Worksheet' object has no attribute 'formula_attributes'

What was expected to happen

After ExcelCompiler(filename=temp_file_name) I should have been able to run column_values = excel.evaluate('sheet_name!J3:J7') and get the values.

Problem description

The init() function within the ExcelCompiler class makes use of the ExcelOpxWrapper class, which in turn makes use of the load() and load_array_formulas() functions. This last function - load_array_formulas() cannot be executed because of a bug in the following code: for address, props in ws.formula_attributes.items(): Since openpyxl's latest updates (10.09.2021, v. 3.0.8, in this particular commit: openpyxl xommit) the formula_attributes mentioned above have been removed, which means that the ExcelCompiler does not work anymore, because the libraries seem to be incompatible at the moment.

Environment

Pycel 1.0b28; Python 3.8; OS: Mac and Linux

stephenrauch commented 3 years ago

@karolinabirecka Thank you for the excellent bug report. Odd that they released a breaking change on patch level version of 3.0.8.

I took a quick cut at resolving the issue, but something else has changed below the hood. Will need to spend a bit more time.

stephenrauch commented 3 years ago

Fixed in 1.0b29

h12sw06 commented 10 months ago

I understand that formula_attributes support has been discontinued since 3.1.0. Is it correct that formula_attributes has been changed to array_formulae? If not, what should I use to do the right thing like formula_attributes?

Thank you in advance