Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open-Xml-SDK cannot load document referencing not installed font when x14ac:knownFonts is present #561

Open
the-frank opened this issue Jan 30, 2019 · 6 comments

Comments

@the-frank
Copy link

Description

Open-Xml-SDK will throw an OpenXmlPackageException with the message "The specified package is invalid. The main part is missing." when an excel file references fonts in worksheets that are not present on the system and the tag x14ac:knownFonts is found.

Information

  • .NET Target: .Net Framework 4.7.1
  • DocumentFormat.OpenXml Version: 2.8.1 and 2.9.0

Repro
We use Open-XML SDK to produce a file (with lots of data) that we give to 3rd parties scattered around the world. They edit that file and send them back for us to import (using Open-Xml SDK again).

Sometimes we have this error from the exception while loading the document using Open-Xml SDK: The specified package is invalid. The main part is missing.

If I save the file with my own Excel application (Excel 2016) prior to import it, I can import the file fine. So I've decompressed the xlsx files and compared both against each other (the one working and the one not working)
The only thing that was different is the presence of the tag x14ac:knownFonts
https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.fonts.knownfonts?view=openxml-2.8.1 Value of the tag is 1. If I remove the worksheet that uses the fonts found in the styles.xml, I can load the document or if I remove the "knownfonts" tag and let the worksheets that reference those fonts: Open-Xml-SDK can open the file successfully again.

Observed

The excel app that was used to save the excel is the same version than me (2016), but installed in Korean language. Two of the fonts referenced have their name in asian characters so my wild guest is that I don't have those fonts on my system, and with the presence of the knownfonts, it causes Open-Xml to die painfully when trying to load that document.

Expected

I would expect that Open-Xml don't die when loading an excel document with if that tag is found (and fonts that I don't have on my system are referenced in that excel document). Excel do not die from actually: it allow me to open the document resave it (effectively removing that infamous "knownfonts" tag.

@twsouthwick
Copy link
Member

Can you share an example of an excel document with this? It definitely shouldn't fail to open.

@the-frank
Copy link
Author

I will as soon as I clear with Legal here, what and how I can share the excel file.

@twsouthwick
Copy link
Member

Awesome. It'll probably be used for a unit test (although we can definitely remove all PII and make it super generic) if that matters for legal purposes.

@twsouthwick
Copy link
Member

@the-frank I'm going to close this unless you have a repro we're able to take a look at. Feel free to re-open.

@dlopatin-v
Copy link

I have the same exception when trying to open word document in a docker container. locally everything works fine

@twsouthwick
Copy link
Member

@dlopatin-v can you share a repro?

@twsouthwick twsouthwick reopened this Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants