Share via

Why are my excel-files considered corrupt if they are only unzipped and then zipped again?

Anonymous
2023-07-05T12:03:36+00:00

I am writing a C# application which modifies excel-files with a third-party library (ClosedXML), but upon saving the files with the library Excel recognizes them as corrupt. I can't open them either by code or by Excel itself. I even asked the maintainer of the library about it but for him/her there was no error.

This is the scenario I have:

  1. Create an empty workbook, save it as an .xlsx file
  2. Rename the file to .zip
  3. Unpack the file to a folder with 7zip
  4. Repack the folder to a .zip file with 7zip
  5. Rename the file to .xlsx
  6. Excel can't open it because it's corrupt.

I changed nothing about the contents of the folder(s) or any of the xml files within the disassembled xlsx file, so how can it be considered corrupt?

Is there a setting in Excel to recognize some xlsx files as corrupt? Are some file attributes missing? What am I missing?

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2023-07-05T16:48:40+00:00

Tested your scenario, issue could be in step 4. You should repack that 4 file instead of that folder. Then it will work.

Image

Was this answer helpful?

4 people found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful