21

I've got simple code to copy files with xlutils, xlrd, xlwt (downloaded new libraries from python-excel.org) with not loosing formatting. I've got an error as below:

from xlwt.Workbook import *
from xlwt.Style import *
from xlrd import open_workbook
from xlutils.copy import copy
import xlrd

style = XFStyle()
rb = open_workbook('file_master.xlsx', formatting_info=True)
wb = copy(rb.get_sheet(0))

new_book = Workbook()
w_sheet = wb.get_sheet(0)
w_sheet.write(6,6)

wb.save('new_file_master.xls')

Error:

 raise NotImplementedError("formatting_info=True not yet implemented")
NotImplementedError: formatting_info=True not yet implemented

Could you please help me how to work around this or rather make it work?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
user1891854
  • 211
  • 1
  • 2
  • 4

1 Answers1

38

According to this thread the flag

formatting_info=True

is only working for xls-files, but not for xlsx yet (Version xlrd-0.8.0).

As a workaround you could convert the workbook to xls using Excel or OpenOffice.

It seems that a commandline conversion from xlsx to xls is possible using Unoconv on Linux, Windows and MacOSX.

Amelse Etomer
  • 1,253
  • 10
  • 28