Attribute Error: 'Workbook' object has no '_date_formats'

Issue #1173 resolved
Nathan Benzschawel created an issue

I just upgraded to openpyxl 2.6.0 and I'm not getting a 'load_workbook" error due to a missing attribute in the Workbook object. I was on 2.5.14 earlier today which did not throw this error. Rolled back to this version in venv.

Anyone else getting this?

File "Documents/com~apple~CloudDocs/Udemy_Python/SEVIS_Application/Handlers/file_imports.py", line 94, in <module> wb_trans = openpyxl.load_workbook(new_transfer_data) File "Documents/com~apple~CloudDocs/Udemy_Python/SEVIS_Application/venv/lib/python3.7/site-packages/openpyxl/reader/excel.py", line 312, in load_workbook reader.read() File "Documents/com~apple~CloudDocs/Udemy_Python/SEVIS_Application/venv/lib/python3.7/site-packages/openpyxl/reader/excel.py", line 274, in read self.read_worksheets() File "Documents/com~apple~CloudDocs/Udemy_Python/SEVIS_Application/venv/lib/python3.7/site-packages/openpyxl/reader/excel.py", line 227, in read_worksheets ws_parser = WorksheetReader(ws, fh, self.shared_strings, self.data_only) File "Documents/com~apple~CloudDocs/Udemy_Python/SEVIS_Application/venv/lib/python3.7/site-packages/openpyxl/worksheet/_reader.py", line 308, in init self.parser = WorkSheetParser(xml_source, shared_strings, data_only, ws.parent.epoch, ws.parent._date_formats) AttributeError: 'Workbook' object has no attribute '_date_formats'

Process finished with exit code 1

Comments (6)

  1. CharlieC

    I suspect this is something in your install. I've been using 2.6 for projects for months and can't reproduce this problem. If the problem persists then please provide a sample file.

  2. Andrey Kolomoets

    Maybe it's because there are no xl/styles.xml in archive and apply_stylesheet doesn't initialize wb._date_formats due to KeyError.

  3. CharlieC

    I really need a file to investigate further because files without stylesheets shouldn't be valuable XLSX files.. As a workaround you can probably monkey patch wb._date_formats = {}

  4. Log in to comment