title: Python: fastest way to write pandas DataFrame to Excel on multiple sheets
body: <p>I need to export 24 pandas data frames <strong>( 140 columns x 400 rows)</strong> to <strong>Excel</strong>, each into a different sheet.</p>
  
  <p>I am using <strong>pandas’</strong> built-in <code>ExcelWriter</code>. Running 24 scenarios, it takes:</p>
  
  <p>51 seconds to write to an <code>.xls</code> file (using <code>xlwt</code>)</p>
  
  <p>86 seconds to write to an <code>.xlsx</code> file (using <code>XlsxWriter</code>)</p>
  
  <p>141 seconds to write to an <code>.xlsm</code> file (using <code>openpyxl</code>)</p>
  
  <p>21 seconds to just run the program (no Excel output)</p>
  
  <p>The problem with writing to <code>.xls</code> is that the spreadsheet contains no formatting styles, so if I open it in Excel, select a column, and click on the ‘comma’ button to format the numbers, it tells me: ‘style comma not found’. I don’t get this problem writing to an <code>.xlsx</code>, but that’s even slower.</p>
  
  <p>Any suggestions on how to make the exporting faster?
  I can’t be the first one to have this problem, yet after hours of searching forums and websites I haven’t found any definite solution.</p>
  
  <p>The only thing I can think of is to use <strong>Python</strong> to export to csv files, and then write an Excel macro to merge all the CSVs into a single spreadsheet.</p>
  
  <p>The <code>.xls</code> file is 10 MB, and the <code>.xlsx</code> 5.2 MB</p>
  
  <p>Thanks!</p>