2

I have a results analysing spreadsheet where i need to enter my raw data into a 8x6 cell 'plate' which has formatted cells to produce the output based on a graph created. This .xlsx file is heavily formatted with formulas for the analysis, and it is a commercial spreadsheet so I cannot replicate these formulas.

I am using python 2.7 to obtain the raw results into a list and I have tried using xlwt and xlutils to copy the spreadsheet to enter the results. When I do this it loses all formatting when I save the file. I am wondering whether there is a different way in which I can make a copy of the spreadsheet to enter my results.

Also when I have used xlutils.copy I can only save the file as a .xls file, not an xlsx, is this the reason why it loses formatting?

trouselife
  • 971
  • 14
  • 36
  • These answers kinda suck, and honestly it's really sad that 2 years in we still don't have a way to paste values-only text to Excel using python. MATLAB has had this for YEARS! and it's a one-liner, too! – 123 Jun 26 '18 at 15:46

2 Answers2

1

First:

Apparently xlwt, does not support xlsx. does xlwt support xlsx Format

Other library to use with format:

https://pypi.python.org/pypi/XlsxWriter

or

http://pythonexcels.com/python-excel-mini-cookbook/

Community
  • 1
  • 1
Destrif
  • 2,104
  • 1
  • 14
  • 22
0

While Destrif is correct, xlutils uses xlwt which doesn't support the .xlsx file format.

However, you will also find that xlsxwritter is unable to write xlrd formatted objects.

Similarly, the python-excel-cookbook he recommends only works if you are running Windows and have excel installed. A better alternative for this would be xlwings as it works for Windows and Mac with Excel installed.

If you are looking for something more platform agnostic, you could try writing your xlsx file using openpyxl.

virtualxtc
  • 390
  • 4
  • 21