Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .nuget/nuget.exe
Binary file not shown.
24 changes: 24 additions & 0 deletions Source/ExcelDna.Integration/ComInterop/ExcelComAddInHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using ExcelDna.ComInterop.ComRegistration;
Expand Down Expand Up @@ -153,6 +155,13 @@ addIn is ExcelRibbon
{
Logger.ComAddIn.Info("Load Ribbon/COM Add-In exception with /K in CommandLine \r\n{0}", ex.ToString());
}
// WPS Office (ET.exe) does not fully support the COM add-in loading mechanism used for
// ribbons and custom task panes. We downgrade the error to Info to avoid a misleading
// error dialog for users running their add-in under WPS.
else if (IsRunningUnderWps())
{
Logger.ComAddIn.Info("Load Ribbon/COM Add-In exception under WPS Office \r\n{0}", ex.ToString());
}
else
{
Logger.ComAddIn.Error(ex, "The Ribbon/COM add-in helper required by add-in {0} could not be registered.\r\nThis may be due to the helper add-in being disabled by Excel.\r\nTo repair, open Disabled items in the Options->Add-Ins page and re-enable target add-in, then restart Excel.\r\n\r\nError details: {1}", DnaLibrary.CurrentLibrary.Name, ex.ToString());
Expand All @@ -170,6 +179,21 @@ internal static void UnloadComAddIns()
}
}

// WPS Sheets (KingSoft Office) uses ET.exe as the host process and does not fully support
// the COM add-in loading mechanism that Excel-DNA relies on for ribbons and CTPs.
private static bool IsRunningUnderWps()
{
try
{
string fileName = Process.GetCurrentProcess().MainModule?.FileName;
return string.Equals(Path.GetFileName(fileName), "ET.EXE", StringComparison.OrdinalIgnoreCase);
}
catch
{
return false;
}
}

}

}