google-apps-script

Find position of a cell containing a specific string

六月ゝ 毕业季﹏ 提交于 2021-02-05 08:54:05
问题 I'm looking for a way to search for a string in a range and get the position of the cell once found. Here's what I use to find the row number var ss = SpreadsheetApp.getActiveSheet(); var values = ss.getRange("B:B").getValues(); var i=rownum=0; for(i=0;i<values.length;i++) { if(values[i]=='string') rownum=i+1; I then use the following code to find the column number var colvalue; for (j=1;j<ss.getLastColumn();j++) { if (ss.getRange(3,j).getValue() == "string" { colvlaue = j; } } Is there a way

“The coordinates of the range are outside the dimensions of the sheet” error when sorting

て烟熏妆下的殇ゞ 提交于 2021-02-05 08:48:06
问题 I am trying to create a script to sort a table on the current active sheet/tab but I am getting an error that I could not identify. I keep getting The coordinates of the range are outside the dimensions of the sheet. . My table has data in them from columnA to columnQ. Data in columnA are identification numbers and columnB to columnQ contain formulas. What am I doing wrong with my script? var sortFirst = 7; //index of column to be sorted by; 1 = column A, 2 = column B, etc. var sortFirstAsc =

Is it possible to change Google sheet sidebar heading background color?

泪湿孤枕 提交于 2021-02-05 08:41:12
问题 I want to change Google sheet sidebar heading background color. Have any idea to change background color using app script or any manual setting. Please help. 回答1: This is probably impossible. The title bar is outside of the iFrame. If there was a way to set this it would be documented in https://developers.google.com/apps-script/reference/html/html-output like the .setTitle() method. However, I see no methods to help in this situation. The best you can get is a titleless bar. 来源: https:/

Showing errors while creating Google Maps URL from a Sheets using App Scripts?

吃可爱长大的小学妹 提交于 2021-02-05 08:40:53
问题 I have latitude and longitude values in a Google Sheet and I want to draw a Google Map URL using App Scripts. I have a paid Google Maps API key but can't find ways to integrate it with my App Scripts code in the Script Editor? While executing the codes, it shows error message, "The Google Maps Platform server rejected your request. You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account" The

Showing errors while creating Google Maps URL from a Sheets using App Scripts?

喜夏-厌秋 提交于 2021-02-05 08:38:46
问题 I have latitude and longitude values in a Google Sheet and I want to draw a Google Map URL using App Scripts. I have a paid Google Maps API key but can't find ways to integrate it with my App Scripts code in the Script Editor? While executing the codes, it shows error message, "The Google Maps Platform server rejected your request. You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account" The

Google Apps Script - convert UrlFetch response to array

一世执手 提交于 2021-02-05 08:38:05
问题 I'm using UrlFetch to get data from a Googe script: var response = UrlFetchApp.fetch(url); Logger.log(response.getContentText()); Logger.log(typeof(response)) This is logging: [["Name","email","2016-12-31T00:00:00.000Z","Sim",548]] object The response looks like an array but it is an object. I need to be able to loop through an array, so how do I convert this data to an array instead? 回答1: It depends on what type of content returned by the query. Suppose, for example, it JSON: function

Google app script only updates document's changes after finishing running. Can I force it to refresh before?

房东的猫 提交于 2021-02-05 08:31:33
问题 I want to replace a piece of text inside a google document and then convert it to PDF Here's the problem, the document is only updated with the changes AFTER the script ends. Because of this when I run the following code, the PDF doesn't have the changes done yet. Is there a way to force it to update while the script is running? var doc_open = DocumentApp.openById(fileid); var doc_body = doc_open.getBody(); //replace text doc_body.replaceText('{name}', student.name); doc_body.replaceText('

How to refresh page, Google app Script Web

爱⌒轻易说出口 提交于 2021-02-05 08:14:13
问题 Good afternoon. I am trying to create a button to refresh the page, through the Google app Script Web, but the method " window.location.reload (); ", does not work could someone help? link Google app Script Web: https://script.google.com/d/1jyWe9jm0dIqHsY1uKJZ0pOJYzLuq9dip1cSsXhxBwv53cFakW2LHgM_n/edit?mid=ACjPJvGbLXQwvhjDh7fsdifcTFvgQby-gsIUWeCSmwUzTdnVvXw8LNckG8rXcsyhcYvAcWAN7pU4E05bQEJwZl_1189N-bwyvttAxpHxmbvzUvx_d9SDKh19x3VzY9XxClhXweVlmqdMOSs&uiv=2 <html> <base target="_se"> <meta name=

Google Sheets: Custom function with dynamic change

筅森魡賤 提交于 2021-02-05 08:09:20
问题 I am using a custom function that keeps track of what color a cell is. But there is a problem in that this function does not update itself if the cell color changes. Cell color: function GetCellColorCode(input) { var ss = SpreadsheetApp.getActiveSpreadsheet(); var cell = ss.getRange(input); var result = cell.getBackground(); return result } Next, I found and add a script that recalculates all the formulas in the table so that they update themselves. I added trigger so that this formula runs

Why am I getting timeout and document missing errors while making parallel calls to Apps Script API?

丶灬走出姿态 提交于 2021-02-05 07:56:07
问题 I'm writing a Google Sheets add-on that copies some data from one spreadsheet to another and then reformats it. The data sets involved are often large (~100k rows), so to avoid hitting the 6-minute timeout limit I break the data into chunks and then run the data-copying function in parallel on each chunk using google.script.run calls from the client side. On my sample data set of ~100k rows, the first couple of chunks to complete are copied successfully, and the rest are throwing the error