Error in parse_auto_filter

Issue #275 resolved
Adam Morris
created an issue

Error reading excel sheet in parse_auto_filter with 1.9.

  File "/Users/amorris/Documents/dev/pycharm/asgedge-amorris/edge/request/handleData.py", line 642, in importTree
    wb = load_workbook(fid[0], data_only=True)
  File "/Library/Python/2.7/site-packages/openpyxl-1.9.0-py2.7.egg/openpyxl/reader/excel.py", line 145, in load_workbook
    _load_workbook(wb, archive, filename, use_iterators, keep_vba)
  File "/Library/Python/2.7/site-packages/openpyxl-1.9.0-py2.7.egg/openpyxl/reader/excel.py", line 209, in _load_workbook
    keep_vba=keep_vba)
  File "/Library/Python/2.7/site-packages/openpyxl-1.9.0-py2.7.egg/openpyxl/reader/worksheet.py", line 311, in read_worksheet
    fast_parse(ws, xml_source, string_table, style_table, color_index)
  File "/Library/Python/2.7/site-packages/openpyxl-1.9.0-py2.7.egg/openpyxl/reader/worksheet.py", line 299, in fast_parse
    parser.parse()
  File "/Library/Python/2.7/site-packages/openpyxl-1.9.0-py2.7.egg/openpyxl/reader/worksheet.py", line 102, in parse
    dispatcher[tag_name](element)
  File "/Library/Python/2.7/site-packages/openpyxl-1.9.0-py2.7.egg/openpyxl/reader/worksheet.py", line 291, in parse_auto_filter
    vals = [f.get("val") for f in safe_iterator(filters, '{%s}filter' % SHEET_MAIN_NS)]
  File "/Library/Python/2.7/site-packages/openpyxl-1.9.0-py2.7.egg/openpyxl/xml/functions.py", line 170, in safe_iterator
    return node.getiterator(tag)
AttributeError: 'NoneType' object has no attribute 'getiterator'

Comments (7)

  1. Adam Morris reporter

    I believe this is the autofilter that is not being read properly:

        <autoFilter ref="A1:BC689">
            <filterColumn colId="2">
                <customFilters>
                    <customFilter operator="notEqual" val=" "/>
                </customFilters>
            </filterColumn>
            <filterColumn colId="49">
                <filters blank="1"/>
            </filterColumn>
            <filterColumn colId="51">
                <filters>
                    <filter val="A"/>
                    <filter val="B"/>
                    <filter val="C"/>
                    <filter val="D"/>
                    <filter val="E"/>
                </filters>
            </filterColumn>
        </autoFilter>
    
  2. Charlie Clark

    Looks like the customFilters are the problem. continueing if filters is None should resolve this. But I might patch safe_iterator to handle None in cases like this.

  3. Log in to comment