问题
Our company develops and distributes a Powerpoint Add-In.
From the AddIn I add CustomXml parts (referenced to the presentation and the slide as well) to a Powerpoint presentation via DocumentFormat.OpenXml SDK V 2.10. Everything is OK with the file.
Then I copy the file to a SharePoint online. It doesn't matter, if I copy via our WebDAV path, a SharePoint website on a browser or the latest possibility via OneDrive.
Subsequently the behavior of that file varies:
- Powerpoint opens the file without problems.
- WinRar opens the file and any included data file without problems.
- 7-Zip opens the file but shows header errors for some included presentation CustomXml itemProperty files.
- Open Xml SDK 2.5 Productivity Tool for Microsoft Office cannot open the file, shows "Cannot open the file. The file contains corrupted data."
- From code the DocumentFormat.OpenXml Api cannot open the file, throws an System.IO.FileFormatException "The file contains corrupted data."
Opening and saving the "corrupted" pptx file with Powerpoint has a healing effect on the file and it can be used with all mentioned programs without any problems. This is our current workaround. But that's not really satisfying.
But after some further inquiries, I found out that it is the used zipper that has a problem with the data in presentation.pptx file. The error's stacktrace shows that the first error is thrown in the Validate method of the ZipIOLocalFileBlock object:
bei MS.Internal.IO.Zip.ZipIOLocalFileBlock.Validate(String fileName, ZipIOCentralDirectoryBlock centralDir, ZipIOCentralDirectoryFileHeader centralDirFileHeader)
bei MS.Internal.IO.Zip.ZipIOLocalFileBlock.SeekableLoad(ZipIOBlockManager blockManager, String fileName)
bei MS.Internal.IO.Zip.ZipIOBlockManager.LoadLocalFileBlock(String zipFileName)
bei MS.Internal.IO.Zip.ZipArchive.GetFile(String zipFileName)
bei MS.Internal.IO.Zip.ZipArchive.GetFiles()
bei System.IO.Packaging.ZipPackage.ContentTypeHelper..ctor(ZipArchive zipArchive, IgnoredItemHelper ignoredItemHelper)
bei System.IO.Packaging.ZipPackage..ctor(String path, FileMode mode, FileAccess access, FileShare share, Boolean streaming)
bei System.IO.Packaging.Package.Open(String path, FileMode packageMode, FileAccess packageAccess, FileShare packageShare, Boolean streaming)
bei System.IO.Packaging.Package.Open(String path, FileMode packageMode, FileAccess packageAccess, FileShare packageShare)
bei DocumentFormat.OpenXml.Packaging.OpenXmlPackage.OpenCore(String path, Boolean readWriteMode)
bei DocumentFormat.OpenXml.Packaging.PresentationDocument.Open(String path, Boolean isEditable, OpenSettings openSettings)
bei DocumentFormat.OpenXml.Packaging.PresentationDocument.Open(String path, Boolean isEditable)
I hope there's someone who knows about pptx file format, the differences between the variants to save a presentation in Powerpoint and OpenXml. (There are some more obvious differences, but usually they seem to be proper variants and don't cause any problems!) and especially what the zipper's validation lead to throw the FileFormatException. Furthermore is it isnteresting, what the sharepoint server changes to our custonXmls. Obviously it adds some own customxmls to office files.
Alternatively I want to go on with my research. Maybe someone can tell me if "System.IO.Packaging" and "WindowsBase" which I expect to contain MS.Internal.IO.Zip are open source and where I can download the projects?
Thank you for help, Karl
来源:https://stackoverflow.com/questions/60164770/powerpoint-presentation-file-reports-to-be-corrupted-after-it-was-copied-to-a-sh