openpyxl+load_workbook+AttributeError: 'NoneType' object has no attribute 'date1904'

Issue #739 resolved
Wei Li
created an issue

Hello, several months before, i met this problem , when i use the openpyxl to load a xlsx file which was created by another sys. When I put it on stackoverflow, there had no reply. So i debug it by myself, at last found that : in xlsx's property, the properties is nothing . According this, i changed the file "openpyxl / openpyxl / packaging /": class WorkbookParser:

def init(self, archive): self.archive = archive self.wb = Workbook() self.sheets = [] self.rels = get_dependents(self.archive, ARC_WORKBOOK_RELS)

def parse(self): src = node = fromstring(src) package = WorkbookPackage.from_tree(node)

if is not None: #add this line 
        wb.excel_base_date = CALENDAR_MAC_1904
    self.wb.code_name = =

The problem is solved. At last ,I pull a request to change it .

The question in stackoverflow is here:

Comments (15)

  1. tonyshouse

    I am having this issue also.

    File "C:\python27\lib\site-packages\openpyxl\packaging\", line 43, in parse if AttributeError: 'NoneType' object has no attribute 'date1904'

    Python 2.7.13 openpyxl 2.4.1

    Windows 10

  2. tonyshouse

    I am working with confidential information in my xlsx files.
    I'm happy to provide my code. Also willing to investigate the xlsx file but can't share it. I can tell you that the xlsx file is one that I prepared and send to many people. openpyxl works on all but one of the files. I don't know how the person that returned the file to me edited the file. The file can be opened without error or warning in Excel 2016.

  3. CharlieC

    It's really difficult without a file but if you unzip the relevant file you should be able to extract the /xl/workbook.xml file from it. You should be able either to attach that file or send it to me only the definedNames node could possibly have anything sensitive in it.

  4. tonyshouse

    1) I'm not sure what you mean by "unzip the relevant file". Can you expand on that or give steps to accomplish? 2) A bit more info has been uncovered about my file. It was created in Excel, edited into a .numbers file then opened by .numbers and saved back to a .xlsx file.

  5. CharlieC

    I don't get the exception. This is the relevant code:

    from openpyxl.xml.functions import fromstring
    from openpyxl.workbook.parser import WorkbookPackage
    with open("739/workbook-normal.xml", "rb") as src:
        xml = fromstring(
    wb = WorkbookPackage.from_tree(xml) is None
    with open("739/workbook-flawed.xml", "rb") as src:
        xml = fromstring(
    wb = WorkbookPackage.from_tree(xml) is None
  6. Log in to comment