I need to export 24 pandas data frames ( 140 columns x 400 rows) to Excel, each into a different sheet.
I am using pandas’<
For what it's worth, this is how I format the output in xlwt. The documentation is (or at least was) pretty spotty so I had to guess most of this!
import xlwt
style = xlwt.XFStyle()
style.font.name = 'Courier'
style.font.height = 180
style.num_format_str = '#,##0'
# ws0 is a worksheet
ws0.write( row, col, value, style )
Also, I believe I duplicated your error message when attempting to format the resulting spreadsheet in excel (office 2010 version). It's weird, but some of the drop down tool bar format options work and some don't. But it looks like they all work fine if I go to "format cells" via a right click.
Here is a benchmark for different Python to Excel modules.
And here is the output for 140 columns x (400 x 24) rows using the latest version of the modules at the time of posting:
Versions:
python : 2.7.7
openpyxl : 2.0.5
pyexcelerate: 0.6.3
xlsxwriter : 0.5.7
xlwt : 0.7.5
Dimensions:
Rows = 9600 (400 x 24)
Cols = 140
Times:
pyexcelerate : 11.85
xlwt : 17.64
xlsxwriter (optimised): 21.63
xlsxwriter : 26.76
openpyxl (optimised): 95.18
openpyxl : 119.29
As with any benchmark the results will depend on Python/module versions, CPU, RAM and Disk I/O and on the benchmark itself. So make sure to verify these results for your own setup.
Also, since you asked specifically about Pandas, please note that PyExcelerate isn't supported.