title: Write a List Into Excel File with Python
body: <p>I have a list to be exported to an Excel file keeping the appropriate format, I resorted to a library named xlsxwriter,</p>
  
  <p>here is an example : 
  <a href="https://xlsxwriter.readthedocs.org/tutorial03.html" rel="nofollow">xlsxwriter</a></p>
  
  <p>and here is my list  :</p>
  
  <pre><code>{'FirstName': u'Forence','LastName': u'Bidorst', 'Salary': -6775000.0, 'BirthDate': datetime.datetime(2013, 6, 20, 0, 0)}
  {'FirstName': u'Oliver','LastName': u'Bidorst', 'Salary': -6775000.0, 'BirthDate': datetime.datetime(2013, 6, 20, 0, 0)}
  {'FirstName': u'Mathew','LastName': u'Stark', 'Salary': -6775000.0, 'BirthDate': datetime.datetime(2013, 6, 20, 0, 0)}
  {'FirstName': u'Sphed','LastName': u'liomst', 'Salary': -6775000.0, 'BirthDate': datetime.datetime(2013, 6, 20, 0, 0)}
  </code></pre>
  
  <p>I modified the code to browse a list and insert it into the file, </p>
  
  <pre><code>def export_result_XL():
   list=get_list()
   ...
  
   # Write some data headers.
   worksheet.write('A1', 'First Name', bold)
   worksheet.write('B1', 'Last Name', bold)
   worksheet.write('C1', 'Salary', bold)
   worksheet.write('D1', 'Birth Date', bold)
  
   # Some data we want to write to the worksheet.
  
   for entry in list:
       x = str(entry['FirstName'])
       y = str(entry['LastName'])
       z = str(entry['Salary'])
       e = str(entry['BirthDate'])
       v = BirthDate[:10]  # because the date format is like yyyy-mm-dd 00:00:00
  
       expenses = (
               [x,y ,z ,v]
                   )
  
   # Start from the first cell below the headers.
   row = 1
   col = 0
  for item ,str1,str2,str3,date_str in (expenses):
   # Convert the date string into a datetime object.
   date = datetime.strptime(date_str, "%Y-%m-%d")
  
   worksheet.write_string  (row, col,     str1              )
   worksheet.write_string  (row, col + 1,     str2              )
   worksheet.write_string(row, col + 2,     str3              )
   worksheet.write_datetime(row, col + 3, date, date_format )
  
  
       row += 1
  
   # Write a total using a formula.
   #worksheet.write(row, 0, 'Total', bold)
   #worksheet.write(row, 2, '=SUM(C2:C5)', money_format)
  
   workbook.close()
  
   return ''
  </code></pre>
  
  <p>I had two problems here :</p>
  
  <p>1 - </p>
  
  <pre><code> for item, date_str in (frais) 
          ValueError: too many values ​​to unpack 
  </code></pre>
  
  <p>2- 
  if I avoid to convert to date format the file will be genreated but columns and rows are flipped</p>
  
  <p>Is there any Idea how to do it , I hope I was clear in the description </p>