recreate excel .xlsx file from unzipped xml folder
Asked Answered
S

2

9

I'm trying to convert a folder of xml that was created by unzipping an excel file back into an excel .xlsx. But I get the error

The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt

A minimal reproducible example to generate this error:

  1. Create a new blank spreadsheet in Excel
  2. Enter "test" in cell A1
  3. Save as test.xlsx
  4. Rename file to test.zip
  5. Unzip test.zip as a folder named test
  6. Compress test into test_new.zip
  7. Rename test_new.zip as test_new.xlsx
  8. Open test_new.xlsx with Excel

For zipping and unzipping I have used 7zip, WinZip and PeaZip, all with the same result. What am I doing wrong, and how can I turn unzipped excel workbooks back into their original form?

Simson answered 19/10, 2016 at 19:12 Comment(1)
Follow this SuperUser post advising not to uncompress zip folder but making edits inside 7Zip (right click item to Edit). Then save to automatically replace in archive.Commonweal
S
23

I managed eventually to find the solution to this myself. The key is that when creating the new zip file, it is necessary to only add the contents of the unzipped folder into the archive. Not the whole folder itself!

Simson answered 20/10, 2016 at 17:46 Comment(0)
S
0

After struggling with this for a few hours the solution I found that worked using WinRAR (v. 5.71 64-bit) and Office 2019 (16.0.13426.20270 32-bit) was:

  1. create a new excel file (e.g. .xlsm)
  2. change it's extension to .zip
  3. extract the contents to whatever folder you want
  4. add the contents (as dww suggests) to a new WinRAR archive. I did this by selecting all the contents, right-click, and selecting "Add to archive...".
  5. In the WinRAR menu and General tab, under Archive format select ZIP
  6. In the WinRAR menu and General tab, under compression method select "fastest"
  7. I did not change any other parameters but here are some defaults that I have (in case your defaults are different). Dictionary size: 32 kB, Split to volumes, size: blank, Update mode: Add and replace files, Archiving options: none are selected
  8. Pick whatever name you want for your new .zip file
  9. Click Ok
  10. Change the extension from .zip to .xlsm
  11. Open your new .xlsm file in excel
Sulfite answered 30/12, 2020 at 22:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.