If you are using
Microsoft.Office.Interop.Excel for Excel related operations in your application, then you must check if Excel is installed in the client machine or not. This tip gives you that trick.
This little piece of code is a result of the research during development of one Windows Utility, which uploads Excel sheets to database.
Using the Code
We will use
Type Class and its method
Type.GetTypeFromProgID Method (String).
Gets the type associated with the specified program identifier (
null if an error is encountered while loading the Type.
The type associated with the specified
progID is a valid entry in the registry and a type is associated with it; otherwise,
For Excel, the
Excel.Application. So, the below code is used to check whether Excel is installed or not.
Type officeType = Type.GetTypeFromProgID("Excel.Application");
if (officeType == null)
- 07 November 2013 - First version submitted for approval