This should work, as described here. It's not a very elegant solution, though, as it is version specific and will break with the next office version. This example is forOffice 2003, so it won't work with Office 2007 without updating.
const string ASSEMBLY2003 = "Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c";
static bool IsAssemblyInstalled(string assembly)
{
try
{
s_assemblyExcel = Assembly.Load(assembly);
return true;
}
catch
{
return false;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…