Excel-DNA / ExcelDna

Excel-DNA - Free and easy .NET for Excel. This repository contains the core Excel-DNA library.
https://excel-dna.net
zlib License
1.3k stars 276 forks source link

Function argument dialog not showing when I use HTMLAgilityPack in a function #261

Open quasar-pankaj opened 5 years ago

quasar-pankaj commented 5 years ago

Hello, I am using Excel Dna with HtmlAgilityPack to build some SEO functions in Excel. While entering the formula manually works perfectly inserting it from the functions wizard doesn't bring up the arguments dialog. Do I need to do anything additional to ensure that the wizard works?

Thanks again, Pankaj

govert commented 5 years ago

@quasar-pankaj This sounds strange - the "Function Arguments" dialog is shown by Excel and you don't need to do anything special to make it work. What is the Excel behaviour you see when selecting your function from the "Insert Function" list and pressing OK?

It might be calculating automatically and not give the right result, e.g. if you are trying to interact with the sheet. You can check inside your function whether the function wizard is showing with a call to ExcelDnaUtil.IsInFunctionWizard.

If it still doesn't show, you could make a very simple function and confirm that it works, and then see which aspect of your own function causes it to break. Then if it is still a problem, you might have to make a small project that we can look at to see if the problem reproduces elsewhere.

quasar-pankaj commented 5 years ago

@govert when I select the insert function button the insert function dialog is shown. Next I select one of my functions and the insert arguments dialog should be shown but it dopes not appear. The function is inserted without any arguments. I have traced this to the use of HtmlAgilityPack. The code works for all other functions except the ones that are using HtmlAgilityPack. The code is passing unit tests without any problems ExcelDNATest.zip This is a small demo I have created to reproduce the problem.

govert commented 5 years ago

I guess there might be an interaction with the Excel dialog being shown, or something like that. I'd suggest you just don't run the function when the dialog is shown, returning some fixed string in that case:

if (ExcelDnaUtil.IsInFunctionWizard)
    return "!!! In Function Wizard";

/// normal code here