File open error with Format error in styles.xml of a password protected .ods

I use LO 7.3.0.1 in Windows 11 environment. I’ve a password protected .ods. When I open it first LO report file corruption issue and asked for repairing it. In the next step of repairing it reports an error “Read Error. Format error discovered in the file in sub-document styles.xml at 1,1(row,col).”.

I was able to find earlier question on how to fix the issues in content.xml and I could apply that to styles.xml. But since my .ods is password protected the styles.xml is not just plain text file instead it is encrypted.

As I know the password, is there any way to decrypt all the associated files and fix the styles.xml error. Or is this a recently found known issue in LO 7.3.0.1.

This is the RC1 (Release Candidate first of three).
You should

  1. Try to open the file with a stable version.
  2. If 1. worked, report a bug against 7.3.0 RC1.

(Read error at the first place of a wrapped-in file isn’t a common case of that kind of errors.)

Hi Lupp, I tried with LO portable 7.2.4.1. It was not able to repair and lands in same error as LO 7.3.0.1.

Is there a way to decrypt my file and fix this error manually? I do not have any recent backup version of my .ods file. So I’ve to fix this error in order to restore it. Please help me.

Hi @sivanbalaji

If the error is in the styles.xml file you can open the archive and simply delete this file. It will be rebuilt when you open it in Calc (custom styles and other changes will be lost of course).

Regards

Hi PYS, Thanks for your idea. I have packed the files without styles.xml as .ods and tried to open that in LO portable 7.2.4.1. It asked for repairing the file and then reported the error “The file ‘$(ARG1)’ could not be repaired and therefore cannot be opened”.

I’ve also tried the same with LO 7.3.0.1. Same error as above.

Is there any way to decrypt the file and take the raw data at least?

There must be. After all LibO can’t state an error inside an wrapped-in encrypted file without first decrypting it.
However, it is a very technical question how it is done, and by what means a user can do it.
I tried the search for “ODF file decrypt” with Startpage and got some probably useful results, but lacking experties and experience, I can’t get the clue.
There also is this page in the API reference, mentioning a method
decrypt(streamIn, streamOut),
but I have no idea how to apply it from user code running for any document instance. .
Some developers surely will know the needed details, but may not come to this ask-site…
@erAck posted abouit the related question How do decrypt content.xml using openssl about a year ago. Probably he learned more since.
That question was merked “solved”.

What did you do except simply deleting the wrapped-in file from the archive? If I simply delete styles.xml from the experimental archive made encrypting a simple Calc doc, and then open the resulting .ods giving the correct password, I don’t get reported an error.

Unfortunately not. I never needed it… and the OP didn’t get back to it to provide findings.

The XPackageEncryption API you mentioned is only for MS-PackageStreams.

ODF stream decryption is handled deep in core code AFAIK without UNO API.

Hi Lupp, I just deleted the styles.xml in the archive and packed the rest as .ods. Nothing more.

I tried ODFind tool mentioned by @erAck but it did not find my .ods at all. I did not try OODecr yet.

My question just was if you needed to pack anything explicitly. I deleted styles.xml without explicit extraction form the archive, and didn’t need to pack anything explicitly.
7-zip 18.05(64) and WinZip 9.0 SR-1 did it the same way. The resulting .ods not containing a styles.xml was opened flawlessly with LibO, and when saving a default styles.xml was created anew.as @PYS stated above.

That’s the problem. Don’t repack the files to a new zip, which can change order and compression algorithms, which for the mimetype file is vital as it has to be the first file in the archive and stored uncompressed. Instead, delete styles.xml from the original zip (after backup…).