javascriptoffice-jsoffice-addinsoffice365apioffice-fabric

Office.js | how to read hidden sheet data from workbook


I am using office.js to create excel add-ins. I am creating hidden sheet with certain json object on click of button from task pane. Now the requirement is if user saves workbook locally using native save option and if he opens workbook again in offline mode and try to launch add-ins at that time wants to read the hidden sheet data and populate it into the task pane.

Please prove the info how I can implement this functionality. It will be helpful. Thanks in advance.


Solution

  • From your comment, it sounds like you're having trouble finding the hidden worksheet.

    You find it either by name, or by searching for a worksheet with the same value for the property you set when you were hiding it: visibility

    context.workbook.worksheets.load("items");
    await context.sync();
    for (const sheet of context.workbook.worksheets.items) {
        sheet.load("visbility");
    }
    await context.sync();
    for (const sheet of context.workbook.worksheets.items) {
        if (sheet.visibility !== "Visible") { // Or === "Hidden" or === "VeryHidden", depending on your code
            // This sheet is hidden
        }
    }