Add-in X: toolkit to build add-in with Excel-DNA

347 views
Skip to first unread message

Amael Noel

unread,
Mar 9, 2016, 10:03:54 AM3/9/16
to Excel-DNA

Hi,


I’ve been working for over 3 years with Excel-DNA for a front office team and during that time, I’ve created few libraries to help me in the implementation process. During the last few months, I’ve been focusing mainly on re-writing those libraries in order to share them as it might be useful for others.


Those libraries are published under the name Add-in X and it is an open-source project hosted on github (https://github.com/AddinX/). Those libraries are available as nuget packages:


  •         AddinX.Ribbon: Fluent ribbon builder for Excel-DNA
  •          AddinX.Bootstrap: Ease the use of an Inversion of controls container (only Autofac for the moment)
  •          AddinX.WPF: Helper method to open a WPF window from Excel
  •          AddinX.Logging: Wrapper to allow user to change easily the logging framework

Base on your needs, you might want to use one or more of the libraries. You decide what you want to include in your project.


You should have a look at the documentation (http://www.addinx.org) which contain examples on how to use the fluent ribbon, call a WCF service, open a WPF window, create a simple add-in with udf. You will also find the samples on the github page of the project.

  •          Sample.Ribbon: All the controls that can be created with the fluent ribbon
  •          Sample.WPF: A WPF wizard window launch from Excel and pushing back data to Excel
  •          Sample.WCF: Calling a WCF service from Excel to say “Hello”
  •          Sample.Addin: 2 simple add-ins

I will be pleased to get your feedbacks and suggestions.


I hope that you will find this toolkit useful!


Amael

Gianfranco Di Tommaso

unread,
May 17, 2016, 10:22:49 AM5/17/16
to Excel-DNA
Hi Amael,
first of all thanks for your work!

I'm trying to use your RibbonBuilder with custom images (not ImageMso) and I've a problem.

I've created a class to return custom images from resource file ( like your example) and I'm trying to assign it to a button, so, I've override OnLoadImage

         public override Bitmap OnLoadImage(string imageName)
        {
            return TestAddIn.ResourceImage.settings_icon;
        }

And assigned a fake image name to the .ImagePath just to call OnLoadImage

                         d.AddButton("Check Update")
                            .SetId("teCheckUpdate")
                            .LargeSize()
                            .ImagePath("test");

OnLoadImage was correctly called but the button didn't have any image. Have you any idea?

Thanks

Gianfranco

Amael N

unread,
May 17, 2016, 11:03:07 AM5/17/16
to exce...@googlegroups.com
Thanks for your feedback,

I've never used ResourceImage before, how does it work ? Could you try to use Properties.Resources.settings_icon, please. 

Could let me know the type of your image please ? is it a jpg or png ? If the extension of your image is a .ico you have to convert it to a bitmap format

try this line 
return
      PictureConverter.IconToPictureDisp(Properties.Resources.MyIcon);

PS: I didn't had time to test it.

Please let me know if it works or not and I will investigate on it more

Thanks,
Amael

kissinger chen

unread,
May 17, 2016, 6:19:33 PM5/17/16
to Excel-DNA
Hi Amael,

I saw your class of "AddinX.WPF/AddinX.WPF.Implementation/ExcelDnaWpfHelper.cs"
It is interested to show dialog a window. Here is window is model so that user cannot click anything under the window, such as the excel cell.

Now I want to show a window modeless, so that user can input something from key board to the window, also user can click the excel range by mouse. Is it possible? and how?

Thanks.

Amael N

unread,
May 18, 2016, 5:08:08 AM5/18/16
to exce...@googlegroups.com
Hi Kissinger Chen,

It is a good practice to have a modal form and separate the manipulation on the WPF form with Excel.

It is possible to do what you want by sending a message to Excel from the WPF form and call the Excel method inputBox from the Add-in then send back the selected range to the WPF form. 

I will provide you some suggestions on how to do it by referring to the Sample.Wpf project.

You can include a button on your form that will send a message to Excel to ask a range to the user. Inside the class WpfInteractionController you will call a method from a class that contain the Excel Application (ExcelInteraction in the WPF Sample) there you will be able to call the Excel function Application.InputBox("Prompt", "Title", , , , , , 8)  (the type 8 return a range).
-  You will need to lookup on internet how to use this method.

Then you will return a message to the WPF form with the range you obtained from the inputbox.

PS: Don't send any message to Excel from a background worker or using a Tasks as the GC will not be able to close your application at the end and you will end up with memory leaks as Excel must be called on the main thread.

Hope that it will help you,

Amael



--
You received this message because you are subscribed to a topic in the Google Groups "Excel-DNA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/exceldna/QI5hPxOT0OI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.



--
Regards,

Amaël NOEL

Govert van Drimmelen

unread,
May 18, 2016, 6:16:08 AM5/18/16
to Excel-DNA
This project examines different ways to make a WinForms or WPF form that still allows mouse selection on the Excel sheet:

It uses a combination of COM event hooks and window message hooks to get this right.

-Govert
To unsubscribe from this group and all its topics, send an email to exceldna+unsubscribe@googlegroups.com.

To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.



--
Regards,

Amaël NOEL

Yselfh (Gianfranco)

unread,
May 24, 2016, 1:50:48 PM5/24/16
to exce...@googlegroups.com
Hi Amael,
thanks for you answers, today I've discovered that with VisualStudio I didn't have any problem, I've that problem only with resource file created by SharpDevelop... Really strange.

--
You received this message because you are subscribed to a topic in the Google Groups "Excel-DNA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/exceldna/QI5hPxOT0OI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to exceldna+u...@googlegroups.com.

To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.



--
Problemi con Excel? Visita il mio sito http://www.tuttoexcel.it

Amael N

unread,
May 25, 2016, 5:49:20 AM5/25/16
to exce...@googlegroups.com
Hi Yselfh,

Thank you for providing us with the solution to your problem.

I never used the IDE SharDevelop before. 

Thanks to the VS Community or VS Code, my life is easier. ;)

Have a good day,

Amael


Regards,

Amaël NOEL
Reply all
Reply to author
Forward
0 new messages