Home > database >  Use Openpyxl to update cells in a file without saving the entire new workbook because it becomes cor
Use Openpyxl to update cells in a file without saving the entire new workbook because it becomes cor

Time:09-13

I am working on openpyxl code to check an excel file for human input errors and correct them. The code works fine for that purpose, but when I save it I cannot open the file because it becomes corrupted.

Upon using load_workbook() I get this error message:

"userwarning: conditional formatting extension is not supported and will be removed"

I can still read data and correct it within the workbook, but I cannot save it because that overwrites the file with a corrupted version that cannot open.

If I could simply write directly to the file without having to load the whole file as a workbook this would be one solution. I have no clue why the formatting extension is not supported in the first place but fixing that could be a second solution.

My openpyxl version is 3.0.4, changing the version I use is not really an option since I am working in an environment with restricted access.

Lastly, the excel file is .xlsm and I am trying to read from and write to that same file

CodePudding user response:

My solution for working with xlsm reading and writing is to use xlwings instead of pandas or openpyxl.

  • Related