Reputation: 19607
I'm using Open XML Format SDK 2.0 to work with Word and Excel documents. I need a possibility to determine type of the document (Word or Excel) by its content, without creating the instances WordprocessingDocument
or SpreadsheetDocument
. How can I do it?
Upvotes: 0
Views: 237
Reputation: 2934
Unzip the docx, xlsx or whatever Microsoft Office document you want to check and then look at the tag
<Application>Microsoft Office Word</Application>
in the app.xml file you can find in the docProps folder. In case it's a .net 4.5 application you can use the new ZipArchive class to extract the xml file in-memory and then lookup the Application Tag.
You can find more details about the internal structure of a Office document in this MSDN article.
Upvotes: 1