OfficeScripts to read various properties of Sheet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

function readSheetProperties() {
  // Get the active worksheet
  var worksheet = context.workbook.getActiveWorksheet();

  // Read sheet properties
  var sheetName = worksheet.name;
  var sheetIndex = worksheet.position;
  var sheetVisibility = worksheet.visibility;
  var sheetProtection = worksheet.protection.isProtected;

  // Logging the sheet properties
  console.log("Sheet Name: " + sheetName);
  console.log("Sheet Index: " + sheetIndex);
  console.log("Sheet Visibility: " + sheetVisibility);
  console.log("Sheet Protection: " + sheetProtection);
}

In this example, the readSheetProperties function performs the following steps:

  1. It gets the active worksheet using the getActiveWorksheet method.

  2. It reads various properties of the sheet, such as the name, position (index), visibility, and protection.

  3. The sheet properties are stored in variables: sheetName, sheetIndex, sheetVisibility, and sheetProtection, respectively.

  4. Finally, it logs the sheet properties to the console.

You can call the readSheetProperties function to see the sheet properties in the console output.

Please note that this example assumes that you have a workbook open and a worksheet active in Excel for the web or Excel Online, where you can execute the OfficeScript.

Additionally, remember to set up the necessary context and load the OfficeScript runtime to ensure the script executes successfully.

Pamai Tech
Turning ideas into Reality

Products

Office Add-in

Enterprise Solutions

Cloud Consulting

UI UX Design

Data Transformation

Services

FAQ's

Privacy Policy

Terms & Condition

Team

Contact Us

Company

About Us

Services

Features

Our Pricing

Latest News

© 2023 Pamai Tech