PydPiper / pylightxl

A light weight, zero dependency, minimal functionality excel read/writer python library
https://pylightxl.readthedocs.io
MIT License
302 stars 47 forks source link

Corrupted excel file when overwritten #81

Closed aescolan closed 1 year ago

aescolan commented 1 year ago

Pylightxl Version: 1.61 Python Version: 3.9.12

Problem appears overwriting an Excel file, with two sheets, which only contains data.

The first time Excel file is generated, it can be opened without any problem, but if it is overwritten again, when it is opened it shows an error.

The problem is solved by deleting the file (if it exists) before overwriting it, but this is a botch.

I attach the code, (code.txt, becaus code.py is not accepted), file created first time (informeOK.xlsx) and file overwritten (informeERR.xlsx)

informeERR.xlsx informeOK.xlsx code.txt

PydPiper commented 1 year ago

Hi @aescolan thanks for posting this. I am held up by school work at the moment, but after this weekend I should be able to take a look and will get back to you with a fix!

PydPiper commented 1 year ago

@aescolan i took a look at what was going on and it actually looks like it's a language encoding issue. The character "ú" cannot be written back to the file using zipfile that pylightxl uses. See https://bugs.python.org/issue38861 for more information. The fix this not super obvious but i'll look into for a little bit more and see what i can do. In the meantime, you could remove special non UTF-8 characters and that should work

PydPiper commented 1 year ago

okay, i got a solution for it that works on my end. Once the other issues are resolved, i will release a new version that will include this fix. Until then please use the master branch version or your temp work-around.