I need to modify some one specific worksheet in an existing xls file and then save it again , using python.
The commonly suggested modules , openpyxl and xlsxwriter , do not support the older xls format.
I tried using the combination of xlrd, xlutils and xlwt. However I'm encountering what seems like a bug in the xlutils copy function. Here is roughly what I'm doing :
rb = xlrd.open_workbook("original.xls",formatting_info = True,on_demand=True)
# .. then some code to read in some data i need ...
wb = xlutils.copy.copy(rb) #use copy to get a xlwt workbook
sheet = wb.get_sheet(sheet_number)
#use sheet.write() to add values i need to add
wb.save("modified.xls")
But due to some weird behaviour of the copy function, cell colors are getting changed across the entire new workbook ( green cells in the original became light blue , purple became dark blue ). Further, cell comments in the original are not present in the modified xls. So :
1) Is this a known bug in xlutils.copy which causes cell colors to change ? If so, is there any workaround for this ?
2) How do I get cell comments from the original to the new xls ?