ExcelFunction Name

149 views
Skip to first unread message

Luis Ortiz

unread,
May 9, 2018, 10:46:25 AM5/9/18
to Excel-DNA
It's possible translate to multiple language the ExcelFunction's Name?

Govert van Drimmelen

unread,
May 9, 2018, 4:49:54 PM5/9/18
to exce...@googlegroups.com
Hi Luis,

First I should note that the functions cannot be translated in the way I understand Excel does, where you can write a sheet under the Spanish culture using Spanish functions names, and then open in English and the functions will then be shown in English.

If you provide localized function names for your Excel add-in, workbooks created with those names won't work when running under a different language.

That said, you can completely control the registration of your function at runtime. The Excel-DNA Registration extensions help you to do this. 



You'd run this code from the AutoOpen():
1. First step is to get all the functions that would normally be registered:
ExcelRegistration.GetExcelFunctions()
is a helper that gives you this.

2. Then you process the list, building up or changing the ExcelFunctionRegistration object until you have to right list for you with the localized names.

3. Finally you call ExcelRegistration.RegisterFunctions(...) with the modified list to register all of them.

-Govert



From: exce...@googlegroups.com [exce...@googlegroups.com] on behalf of Luis Ortiz [mkn...@gmail.com]
Sent: 09 May 2018 04:46 PM
To: Excel-DNA
Subject: [ExcelDna] ExcelFunction Name

It's possible translate to multiple language the ExcelFunction's Name?

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, 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.

Christian Rivera

unread,
Aug 7, 2018, 1:21:09 AM8/7/18
to Excel-DNA
Hi Govert, I tried the exceldna.registration extension and it works, but not  for what I expected,

I don't want to translate the functions, i want to set the name according to the user selection through a form or System language configuration but I notice that excel function attributes must be constants 

 I have created a resource file  and use it as follows:

[ExcelFunction(Name = LangResources.FunctionName, IsMacroType = true, Category = "Categ", Description =  LangResources.FunctionDescr )]
        public static async void GetSomething([ExcelArgument(Description =  LangResources.FunctionDescr )]  object[] obj)
        {
            //my code
        }

Is there a way to build something like this? or maybe the Registration extension does it? for the moment I think i should create two versions Esp and Eng

Hope you can help me explain and undestand up to where it is capable at the moment
To post to this group, send email to exc...@googlegroups.com.

Govert van Drimmelen

unread,
Aug 7, 2018, 3:29:59 AM8/7/18
to exce...@googlegroups.com
By doing the registration explicitly using the ExcelDna.Registration library, you get a chance to completely replace the attribute objects with new ones before you call into the Excel-DNA registration.

Look at the structures you get during the registration 'pipeline' - these have the attributes separately (no longer as metadata on the methods) and can be modified.

-Govert
To post to this group, send email to exce...@googlegroups.com.

Christian Rivera

unread,
Aug 8, 2018, 2:24:26 PM8/8/18
to Excel-DNA
Hola again! Thanks for the feedback, and I tried again implementing the registration library in my Project but I don't get how exactly the extensión Works, I see the library saves and saves a name for the same method, 

I follow the step from https://github.com/Excel-DNA/Registration and in my functions replace to "helpTopic" (I dont get why set this on the functions too, this never is used):

[ExcelFunction(HelpTopic ="FunctionNameInEnglish")]
       
public static async void DoSomething([ExcelArgument(Description =  LangResources.FunctionDescr )]  object[] obj)
       
{
           
//my code
       
}

 
after this I run the Project and it open Excel application, then I try to call my function as =FunctionNameInEnglish but it not appears on the list functions, then I type =DoSomething and it appears on the list, (this is the name of the method!) I notice the library saves (Registered names I was typing before) as FunctionName_InEnglish  and get.functionName_English for the same function

in my AddIn class:

public class AddIn : IExcelAddIn
   
{
       
       
public void AutoOpen()
       
{
           
RegisterFunctions();
           
IntelliSenseServer.Install();
           
       
}
       
public void AutoClose()
       
{
           
IntelliSenseServer.Uninstall();
       
}
       
public void RegisterFunctions()
       
{
           
ExcelRegistration.GetExcelFunctions()
                             
.Select(UpdateHelpTopic)
                             
.RegisterFunctions();
       
}
       
public ExcelFunctionRegistration UpdateHelpTopic(ExcelFunctionRegistration funcReg)
       
{
            funcReg
.FunctionAttribute.HelpTopic = "FunctionNameInEnglish";
           
return funcReg;
       
}
   
}

Govert van Drimmelen

unread,
Aug 9, 2018, 7:42:21 AM8/9/18
to exce...@googlegroups.com
You're close.
Instead of UpdateHelpTopics, you should make your own UpdateFunctionNames method that changes the function attribute's Name property.

-Govert


From: exce...@googlegroups.com [exce...@googlegroups.com] on behalf of Christian Rivera [christia...@gmail.com]
Sent: 08 August 2018 08:24 PM
To: Excel-DNA
Subject: Re: [ExcelDna] ExcelFunction Name

Reply all
Reply to author
Forward
0 new messages