1

I am new to the Advanced Formula Environment. I have created the one testing function using Advanced Formula Environment. I want to get that formula name using office JS. I have tried the following code but I failed to get the formula name.

async function getFormulas() {
    try {
        await Excel.run(async (context) => {
            const sheet = context.workbook;
      
            sheet.load("formulas");

            await context.sync();
            console.log(JSON.stringify(sheet.formulas, null, 4));
        });
    }
    catch (error) {
        console.log(error)
    }
}

Can anyone guide me on How to get the formula name which is created by Advanced formula environment? Test function created by Advanced Formula Environment

1 Answer 1

2

The functions you define in the Advanced Formula Environment add-in are stored as named items in the Excel workbook.

For example, a function called Add...

enter image description here

... will be stored as a named item Add in the workbook:

enter image description here

An add-in can get the names in the workbook using the workbook.names collection.

Use this code to list the named items for a workbook:

  await Excel.run(async (context) => {
    const namedItems = context.workbook.names.load();
    await context.sync();

    console.log("This workbook contains " + namedItems.items.length + " named items.");

    for (let i = 0; i < namedItems.items.length; i++) {
      console.log(JSON.stringify(namedItems.items[i])) + "\n";
    }

    await context.sync();
 });
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your reply. Can you please tell me why there is two-time x, and y in the formula =LAMBDA(x,y,x+y).
It is how the LAMBDA function works. First you list each of the arguments (in the example above x and y) and at last you provide the expression to be evaluated (in the example above x+y).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.