1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Excel-DNA 関数を手動で登録する際のエラーを回避

1
Posted at

関数を手動で登録する。

例えば、次のようにする。

   public void RegisterFunctions()
        {
            // There are various options for wrapping and transforming your functions
            // See the Source\Samples\Registration.Sample project for a comprehensive example
            // Here we just change the attribute before registering the functions
            ExcelRegistration.GetExcelFunctions()
                             .Select(UpdateHelpTopic)
                             .RegisterFunctions(); 

        }

しかし、メインのプロジェクト以外に、別のプロジェクトに関数を配置し、それを上記のコードで登録しようとすると、

Initialization [Error] No objects loaded from ***

と表示される。

回避するには、
外部のプロジェクトに、ダミーで、AutoOpen, AutoCloseを配置しておく。

 public class DummyAddIn : IExcelAddIn {
        public void AutoOpen() { }

        public void AutoClose() {}
    }

Registration across projects within single solution

次の環境が前提。

  • ExcelDNA 1.9.0
  • .NET 8

おそらく、今後改善されるとは思う。

備考

Excel-DNAでは、自動的に関数は登録される。
とはいえ、手動で登録するのが必要な場合もある。今回、ExcelFunctionRegistrationの、FunctionAttribute.Descriptionを、RegisterFunctions()時に、英語から日本語に変更して登録したいためである。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?