openpyxl+load_workbook+AttributeError: 'NoneType' object has no attribute 'date1904'
*Created originally on Bitbucket by [mikewolfli (Wei Li)](https://bitbucket.org/%7Bd7e712fb-0538-407b-8d00-6ee4a6cd7dae%7D/)*
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 / workbook.py":
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 = self.archive.read(ARC_WORKBOOK)
node = fromstring(src)
package = WorkbookPackage.from_tree(node)
if package.properties is not None: #add this line
if package.properties.date1904:
wb.excel_base_date = CALENDAR_MAC_1904
self.wb.code_name = package.properties.codeName
self.wb.active = package.active
The problem is solved.
At last ,I pull a request to change it .
The question in stackoverflow is here:
http://stackoverflow.com/questions/38967587/openpyxlload-workbookattributeerror-nonetype-object-has-no-attribute-date1/39324285?noredirect=1#comment69055961_39324285
*Attachments:* [workbook-flawed.xml](/uploads/9e4b828faef2e1fdf99dbfb06e786084/workbook-flawed.xml)[workbook-normal.xml](/uploads/f6a1ebd04d0393a37ee25a9135d2b2ae/workbook-normal.xml)[workbook.xlsx](/uploads/e8d1a216a888909273f724665c5a1715/workbook.xlsx)
issue