google-apps-script

Can I download file from URL link generated by google apps script

前提是你 提交于 2020-05-11 07:20:07
问题 Please help I'm learning google-apps-script for short time. I want to download file from remote site by url generating from data that stores in my spreadsheet. for example, i have 2 paremeters: Cell1 = val1, val2, ... valN Cell2 = val21, val22, ... val2N I split string from cell data to Arrays and than generate URL. for example: http://mysite.com/files/file.val1.val22.zip Than i need to download file from this link... Can I do this process automaticaly ? 回答1: This example function will

Embed a google form in email with script the way google does it when option include form in email is used

冷暖自知 提交于 2020-05-10 08:53:06
问题 I have to send a form to some people and I do it with a google script. I try to embed the form in the email with this code : https://stackoverflow.com/a/23671529/4305236: var form = FormApp.create('New Form'); .... var url = form.getPublishedUrl(); var response = UrlFetchApp.fetch(url); var htmlBody = HtmlService.createHtmlOutput(response).getContent(); MailApp.sendEmail({ to: email, subject: subject, htmlBody: htmlBody, }); ... But it doesn't send the form the way google does it when the

Google Apps Script Calendar Service: Store and retrieve events using PropertiesService

孤者浪人 提交于 2020-05-09 12:11:42
问题 This code var cal = CalendarApp.getCalendarById("Calendar Id"); var startTime = new Date(1850, 0, 1); var endTime = new Date(2100, 0, 1); var events = cal.getEvents(startTime, endTime); Logger.log(events); var sp = PropertiesService.getScriptProperties(); sp.setProperty("events", JSON.stringify(events)); events = JSON.parse(sp.getProperty("events")); Logger.log(events); returns: Info [CalendarEvent, CalendarEvent, CalendarEvent, CalendarEvent, CalendarEvent] Info [{}, {}, {}, {}, {}] Why is

How do I copy data from an xlsx file in my google drive to a google sheet?

帅比萌擦擦* 提交于 2020-05-09 07:31:40
问题 I have an excel file (.xlsx) saved on my google drive. I want to copy the data from there into a tab in a google sheet file i have already created. I have the following code that runs. But I don't know exactly how to specify the Google Sheet (and tab) to paste the excel data in? `` function run() { try { fileName = fileName || "G:\Shared drives\ExchangeData\DailyVolumes.xlsx"; var excelFile = DriveApp.getFilesByName(fileName).next(); var fileId = excelFile.getId(); var folderId = Drive.Files

How do I copy data from an xlsx file in my google drive to a google sheet?

流过昼夜 提交于 2020-05-09 07:31:06
问题 I have an excel file (.xlsx) saved on my google drive. I want to copy the data from there into a tab in a google sheet file i have already created. I have the following code that runs. But I don't know exactly how to specify the Google Sheet (and tab) to paste the excel data in? `` function run() { try { fileName = fileName || "G:\Shared drives\ExchangeData\DailyVolumes.xlsx"; var excelFile = DriveApp.getFilesByName(fileName).next(); var fileId = excelFile.getId(); var folderId = Drive.Files

Absolute reference with UDF & filtering data in google sheets script

北城余情 提交于 2020-05-09 07:16:07
问题 Hi I am begineer to scripts, here is the code and googlesheet for reference What i am getting what i want to achieve /** *@param quest1 Question of the note *@param quest1 Answer of the note *@customfunction*/ function DMNOTE(quest1,ans1,quest2,ans2,quest3,ans3,) { var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var result = quest1+'-'+ans1+','+quest2+'-'+ans2+','+quest3+'-'+ans3; return result; } I want to achieve absolute reference for "quest" parameter and i want it to

Creating a function that returns a date in Google Sheets

独自空忆成欢 提交于 2020-05-09 06:24:05
问题 I created a function that takes in a date and number of months to add to that date and returns the next date. The function seems to be working perfectly, which I check using DEBUG. The strange thing is when I logger in the returned date using the line below, monthstoadd = 18 date1.setFullYear(2019, 6, 1); returnDate = AddMonths(date1, monthstoadd); // my selfmade function Logger.log("returnDate(1):", returnDate.getMonth(), "/" , returnDate.getDay(), "/", returnDate.getFullYear()); the date in

How to optimise Apps Script code by using arrays to pull data from Google Sheets and format it?

时光总嘲笑我的痴心妄想 提交于 2020-05-07 07:27:31
问题 I have a script that takes data from a gsheet and replaces placeholders on gdoc. I am looking to optimise the script by using arrays instead. This is a sample of my gsheet (the original gsheet spans 1000+ rows and 15+ columns), Original script: function generategdoc() { SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").activate(); var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var lr = ss.getLastRow(); for (var i =2;i<=lr;i++){ if(ss.getRange(i, 1).getValue()){

Cookies or Session on Google Apps Script Webservice

核能气质少年 提交于 2020-05-02 04:32:08
问题 I've created websites before where the server-side code has access to either Cookies on the browser or some sort of Session variables. I have not figured out how to do this with GAS. I can host a website with GAS, but I have no way of seeing the login session when a new page is loaded. How do I do this? I would expect to see this information in the doGet() event, like this: function doGet(e){ e.session.userid; //or something like this } NOTE: Anyone can access my site, even anonymous. So I

Cookies or Session on Google Apps Script Webservice

倾然丶 夕夏残阳落幕 提交于 2020-05-02 04:32:04
问题 I've created websites before where the server-side code has access to either Cookies on the browser or some sort of Session variables. I have not figured out how to do this with GAS. I can host a website with GAS, but I have no way of seeing the login session when a new page is loaded. How do I do this? I would expect to see this information in the doGet() event, like this: function doGet(e){ e.session.userid; //or something like this } NOTE: Anyone can access my site, even anonymous. So I