Utilize Office Scripts to update values across numerous worksheets

Looking for ways to improve the performance of this script, as it currently takes 45 seconds to run. Any ideas?

function main(workbook: ExcelScript.Workbook) {
  try {
  const sheets = workbook.getWorksheets();
  for (let sheet of sheets) {
  const breakCol = sheet.getUsedRange(true);
      const values = breakCol.getValues();
      for (let row of values) {
        for (let cell of row) {
          breakCol.replaceAll("Pass", "", { completeMatch: true });
          breakCol.replaceAll("Fail", "", { completeMatch: true });
          breakCol.replaceAll("Skip", "", { completeMatch: true });
        }
      }
     }
}
catch (e) {
  }
}

Answer №1

Discovered the most efficient approach that completed in just 1.3 seconds:

function main(workbook: ExcelScript.Workbook) {
  let selectedSheet = workbook.getWorksheets();
  const activeWorksheetcount = workbook.getWorksheets().length;
  for (let i = 0; i < activeWorksheetcount; i++) {
    selectedSheet[i].replaceAll("Pass", "", { completeMatch: true, matchCase:true });
    selectedSheet[i].replaceAll("Fail", "", { completeMatch: true, matchCase:true });
    selectedSheet[i].replaceAll("Skip", "", { completeMatch: true, matchCase:true });
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best method for serving cross-site content - JSONP, iframe, or a different approach?

In the process of developing an ad network, I am faced with the task of integrating third-party websites to include my JavaScript and replace specific divs with my content. Choosing which content to serve dynamically into these divs necessitates a cross-s ...

Experiencing difficulties when uploading information to an API in a React JS application

Trying to Send Data via React to Contact Form API Having issues trying to send input data through the API when clicking submit button. The error encountered is that the API call should look like this Example Link However, it calls in a different way Diff ...

What is the best way to collect and store data from various sources in an HTML interface to a Google Spreadsheet?

Currently, I have a spreadsheet with a button that is supposed to link to a function in my Google Apps Script called openInputDialog. The goal is for this button to open an HTML UI where users can input text into five fields. This input should then be adde ...

Dealing with the Angular 7 ExpressionChangedAfterItHasBeenCheckedError in combination with NgsScrollReveal

Utilizing ngScrollReveal triggers a re-render with every scroll event. I am invoking a function through the HTML in this manner: <component [alternate]="toggleAlternate()"> The code for toggleAlternate() is as follows: toggleAlternate() { this.a ...

"Using Mongoose to push objects into an array in a Node.js environment

I am faced with a peculiar issue involving an array of images in my code. Here is the structure: var newImageParams = [ { image_string: "hello", _type: "NORMAL" }, { image_string: "hello", _type: "NORMAL" } ] M ...

Ways to implement JavaScript code in Angular 7 application

I am attempting to create a collapsible navigation bar using MaterializeCSS for mobile screens and I plan to incorporate JavaScript code into it. Can you advise where I should place this JavaScript code? Below is the snippet of code that I intend to inclu ...

Function for testing global variable stub in JavaScript

Currently, I am in the process of writing Unit tests for a React application. Within the page header, the tracking library 'mixpanel' is inserted between <script> tags as outlined in their documentation: . The documentation states that "Th ...

The Angular directive ng-model is not able to return a value

I'm currently troubleshooting an issue with the filters in an older project. Here's the HTML snippet: <input type="text" class="form-control" ng-model="FilterEventsEdit" ng-change="FilterEvents()" ...

TSLint Errors Update: The configuration provided cannot locate implementations for the following rules

After upgrading my tslint to version 4.0.2, I encountered numerous errors like the ones shown below: Could not find implementations for the following rules specified in the configuration: directive-selector-name component-selector-name directi ...

Iterating through elements to set the width of a container

I am currently working on a function that dynamically adjusts the width of an element using JavaScript. Here is my JavaScript code: <script> $('.progress-fill span').each(function(){ var percent = $(this).html(); if(per ...

Identify Numerous Unique HTML-5 Attributes within a Single Page - Adobe DTM

Is there a way to automatically detect and aggregate multiple custom HTML-5 attributes, such as "data-analytics-exp-name," into a cookie using Adobe DTM without user interaction? These attributes would only need to exist on the page and not require any cli ...

Modifying an object property within a state container array in React using Hooks' useState

As a React beginner, I decided to create a simple Todo app. This app allows users to add tasks, delete all tasks, or delete individual tasks. The Todo Form component consists of an input field and two buttons - one for adding a task and the other for dele ...

Code error: JSON unexpected token "&" encountered

When utilizing the $http.get() method for a GET request, the response is in JSON format, but some characters are HTML encoded. For example, the double quote " is encoded as &quot;. { &quot;description&quot;:&quot;invalid&quot;, ...

Implementing a Div response within the actionPerformed method

I've spent hours working on this javascript/ajax code trying to get it to add a div response that was echoed by a php script. Any assistance with this would be greatly appreciated. <form id="form1" name="form1" method="post" enctype="multipart/for ...

Implementing nested popup windows using Bootstrap

I am facing an issue with my two-page sign-in and sign-up setup in the header of my angular2 project. On the sign-up page, I have a link that should redirect to the sign-in page when clicked, but I am struggling to make it work. Can someone provide guidanc ...

Certain public files in Express cannot be accessed locally

While running my Node.js application on localhost, I am able to access http://localhost:3000/css/dashboard.css without any issues. However, when attempting to access http://localhost:3000/css/logo.png for a logo image in the same directory, all I receive i ...

Adjust website content depending on user's authentication status

My goal is to display a logout button when the user is logged in and a login button if they are not. I am using JSON tokens to determine if a user is logged in or not, by checking if the token is null. However, this approach does not seem to be working. Ca ...

Modifying a Nested Component with react-icons

As I work on creating a rating component that utilizes react-icons to display icons, I have encountered an interesting challenge. Currently, I am using the FaStarhalf icon which represents a pre-filled half star that can be flipped to give the appearance o ...

The selector often yields varying results when used in a traditional browser versus when it is utilized with Selenium

When using Firefox in the console, I can enter: $("a:contains('tekst')") and it will display: object { length: 1, ... } However, when attempting the same in firefox opened by behat with sellenium, I receive the error message: SyntaxError: An ...

Is it possible to dynamically pass a component to a generic component in React?

Currently using Angular2+ and in need of passing a content component to a generic modal component. Which Component Should Pass the Content Component? openModal() { // open the modal component const modalRef = this.modalService.open(NgbdModalCompo ...