title: Download Excel Spreadsheet Python
body: <p>I am still pretty new to Python, so perhaps I am missing something obvious. I am trying to download a simple spreadsheet from Google Docs, save the file, and open it in Excel. When I did a test run with text files instead of excel files, it worked fine. However, using xls and xlsx, when excel opens the newly downloaded file, it says that the data is corrupted. How can I fix this?</p>
  
  <pre><code>import urllib2
  
  print "Downloading..."
  myfile = urllib2.urlopen("https://docs.google.com/spreadsheet/pub?key=0AoJYUIVnE85odGZxVHkybGxYRXF1TFpuQXdqZlJwNXc&amp;output=xls")
  output = open('C:\\Users\\Lucas\\Desktop\\downloaded.xlsx', 'w')
  output.write(myfile.read())
  output.close()
  print "Done"
  
  import subprocess
  subprocess.call(['C:\\Program Files (x86)\\Microsoft Office\\Office14\\EXCEL.exe', 'C:\\Users\\Lucas\\Desktop\\downloaded.xlsx'])
  </code></pre>