Viktor
Viktor

Reputation: 580

Openpyxl , how to preserve .xlsx file style which was before , after saving it with openpyxl .save() function?

I have an issue with openpyxl library.

Problem:

When I used xlwt, opened an .xls file, and wrote some cells in there, the styles of cells I didn't touch remained the same. But now I have to work with xlsx documents, so I chose openpyxl for this. But after saving it with a .save function, it completely strips the style of a document, even the cells I didn't touch at all.

Any suggestions on how I can preserve the style?

Upvotes: 2

Views: 6677

Answers (2)

Haohan Li
Haohan Li

Reputation: 51

I don't think openpyxl solved this issue yet. You can try pywin32 to directly interact with windows API with Excel, you can do everything there you want.

Upvotes: 1

A Alstone
A Alstone

Reputation: 1167

I'm having this exact problem, apparently there is no good way to preserve the styles in openpyxl, see Use openpyxl to edit a Excel2007 file (.xlsx) without changing its own styles?

Upvotes: 3

Related Questions