WorkbookProtection corrupts Spreadsheet for Excel 2019
See original GitHub issueSpreadsheets saved with Excel 2019 get corrupted as soon as you add a WorkbookProtection.
Information
- .NET Target: .NET 3.5
- DocumentFormat.OpenXml Version: 2.9.1, 2.10.0-beta0001
Repro
Create an empty spreadsheet in Excel 2019. Perform the following operation:
using (var document = SpreadsheetDocument.Open("...", true) {
document.WorkbookPart.Workbook.WorkbookProtection = new WorkbookProtection();
}
Open the spreadsheet in Excel 2019.
Observed
Excel fails to open and repair the file.
The resulting workbook.xml contains the newly added x:workbookProtection
followed by the x:revisionPtr
.
<x:workbookProtection />
<xr:revisionPtr revIDLastSave="0" documentId="13_ncr:1_{4BF1E7C4-2F1B-4756-81DA-B102ED8D212D}" xr6:coauthVersionLast="36" xr6:coauthVersionMax="36" xr10:uidLastSave="{00000000-0000-0000-0000-000000000000}" />
Manually changing the order (unzip/edit/zip) repairs the file.
<xr:revisionPtr revIDLastSave="0" documentId="13_ncr:1_{4BF1E7C4-2F1B-4756-81DA-B102ED8D212D}" xr6:coauthVersionLast="36" xr6:coauthVersionMax="36" xr10:uidLastSave="{00000000-0000-0000-0000-000000000000}" />
<x:workbookProtection />
Expected
File should not get corrupted.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
WorkbookProtection corrupts Spreadsheet for Excel 2019
Spreadsheets saved with Excel 2019 get corrupted as soon as you add a WorkbookProtection. ... Open the spreadsheet in Excel 2019. ... Excel...
Read more >Repairing a corrupted workbook
When you open a workbook that has been corrupted, Excel automatically ... In the Open dialog box, select the corrupted workbook that you...
Read more >Can no longer refresh data in a Protected Workbook since ...
We have a protected workbook with some data connections to pull in data from SQL. Since updating to version 1803 the message 'Workbook...
Read more >Solved: File contains corrupted data
I have tried to remove workbook protection "Restrict access (Highly confidential)" in my case and now it works. I'm able to connect from...
Read more >How to protect worksheets and unprotect Excel sheet ...
To remove the workbook protection, do the following: Click the Protect Workbook button again (in a locked workbook, it is highlighted in green ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Stale issue message
Any progress on this one? I’d be happy to provide more information if required.