You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @benzkji, olefile works on raw data in streams, there is no difference between Word and Excel at that level. So the results you get in Word and Excel depend on which bytes you change in a stream: if those bytes are just text, it should work fine. But if you change bytes that are not part of plain text areas, you may get random results.
Thx! I created my basic .doc in open office, may this be the problem? I just wrote some random chars, some linebreaks, then my text to replace, then again some text. no formatting, just text...It really may be open office. Will organize another file :|
my experience is that word docs are saved with many \x00 , say null bytes?, in between real characters...even when only very simple text is used. I was able to develop a workaround: When the original search was not found, create a new bytearray, that is based on the original, with null bytes between all characters...
Is your feature request related to a problem? Please describe.
Docs suggest one can only do a replace, when having opened a .doc file - https://olefile.readthedocs.io/en/latest/Howto.html#overwriting-a-stream - my experience is different, it seems to work in .xls files, but not in .doc? See also, better explanation of the problem: https://stackoverflow.com/questions/55417274/replace-a-text-in-a-doc-file-with-the-olefile-python-library
Describe the solution you'd like
Update docs so it's clear that not all streams are equal.
Describe alternatives you've considered
I guess there are none?
The text was updated successfully, but these errors were encountered: