title: write xlsx file using openpyxl module in python
body: <p>I am having trouble writing to excel file using openpyxl module. So far I am able to write this code</p>
  
  <pre><code>from openpyxl.workbook import Workbook
  import datetime
  
  header = [u'Name', u'Email', u'Mobile', u'Current location',]
  new_data = [
                 [u'name1', u'email1@yahoo.com', 9929283421.0, u'xxxx'], 
                 [u'name2', u'email2@xyz.com', 9994191988.0, u'xxxx']
             ]
  wb = Workbook()
  cur_date = str(datetime.date.today())
  log_file = "%s/%s_%s_errorlog.xlsx" % (settings.MEDIA_ROOT,
                                         os.path.splitext(file_name)[0], 
                                         cur_date)
  log_csv = wb.worksheets[0]
  
  for i in range(1, len(header) + 1):
      log_csv.cell(row = 1 ,column = i).value = header[i - 1]
  
  wb.save(log_file)
  
  error_count = 0
  for each_row in new_data:
      error_count += 1
      for i in range(1, len(each_row) + 1):
          log_csv.cell(row = error_count ,column = i).value = each_row[i - 1]
  
  wb.save(log)
  </code></pre>
  
  <p>File is created, but it is corrupted and I am not able to open it with the excel file reader (LibreOffice) provided by the OS (ubuntu). Also the contents of the file are not readable. Not sure what I am doing wrong</p>