'Excel Custom Function is not shown

I am creating an Excel custom function inside an office add-in. My starting point was Visual Studio 2017 scaffolding.

In my manifest I have

<FunctionFile resid="Contoso.DesktopFunctionFile.Url" />

where

<bt:Url id="Contoso.DesktopFunctionFile.Url" th:DefaultValue="${baseUrl+'/Functions/FunctionFile.html'}" />

The FunctionFile.html is the file generated by Visual Studio

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <title></title>
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>
    
    <script src="FunctionFile.js" type="text/javascript"></script>
</head>
<body>
    <!-- NOTA: il corpo è intenzionalmente vuoto. Dal momento che viene richiamato tramite un pulsante, non esiste interfaccia utente di cui eseguire il rendering. -->
</body>
</html>         

And in FunctionFile.js I put

(function () {
    Office.initialize = function (reason) {
        function sum(var1, var2){
            return  var1+var2;
        }
    };
})();

Excel Ignores function "sum" but other features of my plugin work. Is FunctionFile.js inside Office.initialize the correct place to define custom functions?

Where can I set the namespace for my functions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source