How to get format from multiple NamedItems in Excel with Office.js?

I’m trying to retrieve some formatting info from a list of NamedItems. Basically, my spreadsheet has a few named ranges spread across multiple worksheets and I want to get some formatting information like font size for each of these named ranges.

This is what I have so far:

async function getRangesAndJson() {
  // 1. Find all prz ranges in file
  let myRanges = await Excel.run(async ctx => {
    const namedRangesInFile = ctx.workbook.names;
    namedRangesInFile.load("items");
    await ctx.sync();
    return namedRangesInFile.items.filter(range => range.name.startsWith("abc_"));
  }).catch(error => {
    console.log("error: " + error);
    if (error instanceof OfficeExtension.Error) {
      console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
  });

  // 2. Extract their formatting in JSON, one by one
  await Excel.run(async function(ctx) {
    for (let index = 0; index < myRanges.length; index++) {
      const namedRange = myRanges[index];
      const range = namedRange.getRange();
    }
    await ctx.sync();
  }).catch(error => {
    console.log("error: " + error);
    if (error instanceof OfficeExtension.Error) {
      console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
  });
}

I’m not sure how to do this, especially since this operation requires looping a lot.
What would be the best way to achieve this?

113 thoughts on “How to get format from multiple NamedItems in Excel with Office.js?”

  1. pharmacie de beaulieu sur loire pharmacie ouverte bourges , traitement termites pharmacie verdun argenteuil , Cytotec pharmacie Luxembourg, Cytotec livraison Luxembourg. Cytotec pharmacie Luxembourg Cytotec pas cher [url=https://francetopters.asso-web.com/#]Acheter Cytotec 200 mcg pas cher, Cytotec pharmacie Luxembourg[/url] pharmacie brest ouverte samedi Ivermectine moins cher, Ivermectine livraison QuГ©bec. Ivermectine pharmacie QuГ©bec Ivermectine pas cher [url=https://canada72sert.asso-web.com/#]Ivermectine pas cher[/url] , act therapy tools pharmacie minimes aix en provence , pharmacie de garde aujourd’hui porto vecchio. pharmacie leclerc quimperle Lyrica livraison Belgique, Lyrica livraison Belgique. Lyrica pharmacie Belgique Lyrica pas cher [url=https://belgiquerwtai.asso-web.com/#]Lyrica sans ordonnance Belgique[/url] , act therapy in a nutshell pharmacie de garde marseille le 16 aout 2020, therapie cognitivo comportementale alger pharmacie de garde beauvais 2018 . du therapies comportementales et cognitives de l’universite paris descartes, traitement lyme therapies innovantes definition pharmacie leclerc vannes .

    Reply

Leave a Comment