RtdServer ベースのオートメーション アドインを使用しています:
RtdServer を使用して C# でリアルタイム Excel オートメーション アドインを作成するにはどうすればよいですか? .
VBA ラッパーの作成は簡単です。
Function RtdWrapper(start)
RtdWrapper = Excel.Application.WorksheetFunction.RTD("StackOverflow.RtdServer.ProgId", "", start)
End Function
これは機能します。次のように C# ラッパーを作成しようとしました。
[ClassInterface(ClassInterfaceType.AutoDual)]
public class RtdWrappers
{
private readonly Microsoft.Office.Interop.Excel.Application _application = new Application();
public object Countdown(object startingCount)
{
var start = Convert.ToInt32(startingCount.ToString());
return _application.WorksheetFunction.RTD("StackOverflow.RtdServer.ProgId", string.Empty, start);
}
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Programmable");
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type t)
{
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Programmable");
}
}
Excel のセルに「=Countdown(150)」と入力すると、ConnectData によって返される初期値の 150 が表示されますが、更新されません。登録すべきコールバックはありますか? Application オブジェクトを正しくインスタンス化していますか? 私は何が欠けていますか?
ありがとう、
フランク