google-apps-script

How do I delete a sheet/tab in a Google spreadsheet pragmatically using GAS/Javascript

徘徊边缘 提交于 2020-04-30 08:46:47
问题 I have a code that dynamically creates new sheets based on the first-row value in the main sheet. I would like to have the code to check the existence of the sheet name and overwrite the sheet or delete it first if it exists and then creates it afresh from the new data in main sheet. I will appreciate your help in restructuring. function newSheet() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var templateSheet = ss.getActiveSheet(); var sheet1 = ss.getSheetByName("main") var getNames = [

How to set values in new column with validation from a Named Range?

我们两清 提交于 2020-04-30 08:46:47
问题 Following a previous question I want to classify text entries by adding a tag in the next column. I could do it using regex but it will take too much time writing all conditions like : if(String(data[i][0]).match(/acme|brooshire|dillons|target|heb|costco/gi)) { labValues[i][0]='Supermarket'; } Instead I created a named list with all stores names (in another sheet). If an entry matches a term in the list, the next column is set to " Supermarket ". I am using this script below... No bugs but

How do I delete a sheet/tab in a Google spreadsheet pragmatically using GAS/Javascript

自古美人都是妖i 提交于 2020-04-30 08:46:27
问题 I have a code that dynamically creates new sheets based on the first-row value in the main sheet. I would like to have the code to check the existence of the sheet name and overwrite the sheet or delete it first if it exists and then creates it afresh from the new data in main sheet. I will appreciate your help in restructuring. function newSheet() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var templateSheet = ss.getActiveSheet(); var sheet1 = ss.getSheetByName("main") var getNames = [

Emailing Google Sheet as PDF

时光怂恿深爱的人放手 提交于 2020-04-30 06:49:06
问题 I have this script that emails me a PDF of the Google Spreadsheet. I only want it to email me the first 'Tab' and if possible as a single PDF vice a zip file. Wondered if anyone could help. Also one of the 'Tabs' are hidden, so I don't know if that has an impact. He is a link to the sample sheet. The code is shown below: /* Send Spreadsheet in an email as PDF, automatically */ function emailSpreadsheetAsPDF() { // Send the PDF of the spreadsheet to this email address var email = "xxxxx@gmail

Loading stock quotes from TD Ameritrade developer app into Sheets with Google Script

给你一囗甜甜゛ 提交于 2020-04-30 06:39:28
问题 I'm trying to use an API from TD Ameritrade to load stock info into a Google Sheet. I've tried the following code: var ticker = "APPL" var headers = {"Authorization":" Bearer <access token>"} var options = {"headers":headers} var calltoAPI=urlFetchApp.fetch("https://api.tdameritrade.com/v1/marketdata/"+ticker+"/quotes?apikey=<myapikey>",options); I get the error: ReferenceError: urlFetchApp is not defined (line 6, file "Code"). However, in my developer app, I do get a return on APPL. Worth

Loading stock quotes from TD Ameritrade developer app into Sheets with Google Script

落爺英雄遲暮 提交于 2020-04-30 06:39:10
问题 I'm trying to use an API from TD Ameritrade to load stock info into a Google Sheet. I've tried the following code: var ticker = "APPL" var headers = {"Authorization":" Bearer <access token>"} var options = {"headers":headers} var calltoAPI=urlFetchApp.fetch("https://api.tdameritrade.com/v1/marketdata/"+ticker+"/quotes?apikey=<myapikey>",options); I get the error: ReferenceError: urlFetchApp is not defined (line 6, file "Code"). However, in my developer app, I do get a return on APPL. Worth

Mail range not whole sheet - apps script

做~自己de王妃 提交于 2020-04-30 06:33:46
问题 I have a Google Sheet. I'd like to mail that out as a PDF. The below code works to email the WHOLE sheet (one tab) as pdf. The &range doesn't do anything. I want it to, but it doesn't. Question: How can I change this code so it emails 'selected cells'? Bonus Question: why do I have to put ?exportFormat=pdf and &format=pdf? var url_base = ss.getUrl().replace(/edit$/,''); var url_ext = 'export?exportFormat=pdf&format=pdf' //export as pdf + (sheetId ? ('&gid=' + sheetId) : ('&id=' + ssId)) + '

How can i specify the guest status so it will put the names in the right cell?

微笑、不失礼 提交于 2020-04-30 06:25:48
问题 I am very new to this kind of programming. To start the code i followed some tutorials and searched for info on this website. I want to build a system that lets me automaticcly retrive info from my google calendar. the info i want from my calendar is:Name event, starttime, endtime, location, description, event guests and there status. I made the following code, i am stuck. I get my guests but not there status. I want the confirmed guests emailadresses in colum 6, and want the people ho had

How to pass templated variables to server-side handler functions in HTML files using Google Apps Script?

时间秒杀一切 提交于 2020-04-30 06:25:26
问题 Follow up to this answer. https://stackoverflow.com/a/60073413/1640892 I want to pass a templated object variable to a server side function in GAS. I expect to see the buttons render, then after filling out the payment details and clicking pay, I expect to see the handleTxn() function successfully execute using the content object as one of its arguments. But, instead, nothing happens because the buttons do not even render. It fails silently. var content = <?!= content ?>; google.script.run

How to pass templated variables to server-side handler functions in HTML files using Google Apps Script?

二次信任 提交于 2020-04-30 06:25:12
问题 Follow up to this answer. https://stackoverflow.com/a/60073413/1640892 I want to pass a templated object variable to a server side function in GAS. I expect to see the buttons render, then after filling out the payment details and clicking pay, I expect to see the handleTxn() function successfully execute using the content object as one of its arguments. But, instead, nothing happens because the buttons do not even render. It fails silently. var content = <?!= content ?>; google.script.run