title: Proper rendering of Flask produced CSV files in Excel
body: <p>Here is a minimal example of a flask view, which produces a CSV (python 2.7).</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  import csv
  import StringIO
  
  from flask import Flask, Response
  
  app = Flask(__name__)
  
  
  @app.route('/example.csv')
  def example_csv():
      f = StringIO.StringIO()
      writer = csv.writer(f)
      writer.writerow(['Header 1', 'Header 2', 'Header 3'])
      writer.writerows([unicode(_).encode('utf-8') for _ in row] for row in (['1', '2', '3'], 
                                                                             ['a', 'b', 'c'],
                                                                             [u'£', u'€', u'¥']))
      response = Response(f.getvalue(), mimetype='text/csv')
      response.headers['Content-Disposition'] = u'attachment; filename=example.csv'
      return response
  
  
  if __name__ == '__main__':
       app.run(debug=True)
  </code></pre>
  
  <p>Opening in Excel gives:</p>
  
  <pre><code>Header 1    Header 2    Header 3
  1   2   3
  a   b   c
  Â£  â‚¬ Â¥
  </code></pre>
  
  <p>With Apple's Numbers App, the last line renders properly. How can I get Excel to render properly? Am I missing some sort of encoding setting?</p>