title: Sorting and auto filtering Excel with openpyxl
body: <p>I am trying to sort a spreadsheet using openpyxl and Python. I have read the documents and I don't quite understand this page. I am expecting it to either add the auto filter dropdown arrows or sort my spreadsheet and it is returning errors. Here's my code</p>
  
  <pre><code>wb = openpyxl.load_workbook('report.xlsx')
  ws = wb.active
  ws['A2'] = "Store"
  ws['B2'] = "Manager"
  ws['C2'] = "Zone"
  ws.column_dimensions.group('F','DU',hidden=True)
  #ws.AutoFilter.add_sort_condition('C:C')
  wb.save("report.xlsx")
  </code></pre>
  
  <p>According to the documents it looks like the line "ws.AutoFilter.add_sort_condition('C:C')" should give me the result I want. (Yes I understand it is currently a comment line. The rest of my code runs fine without that line so I commented it.)</p>
  
  <p>When I have that line in the code I get the error - 'Worksheet' object has no attribute 'AutoFilter' but according to the documents it looks like it does. <a href="http://openpyxl.readthedocs.org/en/latest/_modules/openpyxl/worksheet/filters.html#AutoFilter" rel="nofollow">http://openpyxl.readthedocs.org/en/latest/_modules/openpyxl/worksheet/filters.html#AutoFilter</a>.</p>
  
  <p>If anyone can help explain to me why it is failing or what the documents mean that would be great.  </p>
  
  <p>This statement in the documents is particularly confusing to me:  </p>
  
  <blockquote>
    <p>"Don't create auto filters by yourself. It is created by :class:<code>~openpyxl.worksheet.Worksheet</code>.
        You can use via :attr:<code>~~openpyxl.worksheet.Worksheet.auto_filter</code> attribute."  </p>
  </blockquote>
  
  <p>because I tried that too and it also failed. </p>
  
  <p>Update: @crussell's reply worked in that it added the auto filter to my spreadsheet. However, it is still not adding the sort condition to the appropriate column.</p>