0

I want to modify a string in a xlsx file using xlrd and xlutils.

There were solutions, one from stackoverflow and other from YouTube for xls files.

However, these solution works only for xls format. I tried using these for xlsx format but that corrupts the file.

Are there solutions when using the xlsx file? Or should I use other packages to solve this?

-Best Regards

David Badger
  • 167
  • 6

1 Answers1

1

xlutils relies on xlrd (to read files) and xlwt (to write files) packages as stated here.

xlwt can only write .xls formatted files.

For reading .xlsx formatted files one should use openpyxl or XLRD. For writing to .xlsx formatted files one should use openpyxl or xlsxwritter.

Alternatively, if you will be running the code on a machine that has Microsoft Excel installed, you might want to try xlwings.

Gotcha: According to jmcnamara xlrd and xlsxwritter formats are different object types, thus, despite the fact that both can be used on .xlsx files, one would need to write a translator to be able to write a xlrd formatted file using xlsxwritter.

virtualxtc
  • 390
  • 4
  • 21