none
How to write a formula from Javascript Api in Excel, that is independent from the user language? RRS feed

  • Question

  • What I do:

    var myTable = new Office.TableData(); ..... var y = []; y.push(...); ..... y.push('=SUM(Test[@[364]:[0]])/365'); y.push(...); ..... myTable.rows.push(y);

    .....

    binding.addRowsAsync(myTable.rows, function (addResult){....});

    Now everything is OK, if the user uses English in Excel. But if he uses a German, there comes "#NAME?", because in German SUM have to be SUMME. How to write a formula from Javascript Api, that is independent from the user language?


    Mottor

    Wednesday, July 20, 2016 1:24 PM

Answers

  • Hi Mottor,

    >> How to write a formula from Javascript Api, that is independent from the user language?

    We could not write formula which is independent from user language, but we could write correct formula according the different user language. We could use Context.displayLanguage or Context.contentLanguage to specifies the language of the user interface of host application, and then write the corresponding formula.

    A simple code:

        function sayHelloWithDisplayLanguage() {
            var myLanguage = Office.context.displayLanguage;
            switch (myLanguage) {
                case 'en-US':
                    write('Hello!');
                    break;
                case 'fr-FR':
                    write('Bonjour!');
                    break;
            }
        }
        // Function that writes to a div with id='message' on the page.
            function write(message){
            document.getElementById('message').innerText += message; 
         }

    You could refer the link below for more information.

    # Localization for Office Add-ins
    http://dev.office.com/docs/add-ins/develop/localization

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by Mottor Thursday, July 21, 2016 8:11 AM
    Thursday, July 21, 2016 5:51 AM