google-apps-script

Import csv data into google sheets using apps script

隐身守侯 提交于 2021-01-29 20:37:38
问题 I would like to import a csv file into Google Sheets using Apps Script. I would like to add the csv file to be read to the existing tab "csv_data" after the last line. Can someone help me? I am a starting apps script user. Thank you in advance for your help! GJM 回答1: There is a useful method, called Utilities.parseCsv() If your csv file is located on your Google drive, you can import and append it e.g. by attaching to your spreadsheet a bound script with the following content: function

Google apps script html template issue

醉酒当歌 提交于 2021-01-29 20:25:34
问题 How can I use a function that returns html within a string, inside a html template in google apps script ? For example, here is my code.gs: function doGet() { return HtmlService.createTemplateFromFile('test').evaluate(); } function getHtml(){ return "<b> hello there </b>"; } and in my html file 'test.html' I have the following: <html> <?= getHtml() ?> </html> You will see the result is something like this: How can I change this so it produces hello there in bold, without showing the tags ?

Google Apps Script/URLFetchApp and using returned data

旧城冷巷雨未停 提交于 2021-01-29 20:11:36
问题 I am very new to this, so please bear with me-- I have currently have an operational google apps script on the backend of a google sheet that is generated from Google Form answers. I am essentially setting up a ticket form in google forms that will trigger the data in the corresponding sheet to be sent via api call to our ticketing system. It works great, but I am trying to optimize it currently. The goal is to take the json response I get using: Logger.log(response.getContentText()); which

Triggering a cloud function from google sheets (via google apps script)

被刻印的时光 ゝ 提交于 2021-01-29 19:58:18
问题 I have been trying (with little success) to have a google cloud function be triggered via an http request from a google sheet (google apps script) and it seemingly won't work. A few important things: The function should only run if the user comes from my organization The user should not have to be invited to the GCP project I know this can be done very easily in google colabs and Python. The following script will let a user in my organization who is not in the GCP project trigger the cloud

OnEdit Function without Manual EDIT

旧巷老猫 提交于 2021-01-29 19:57:01
问题 I use an OnEdit function to move data to another sheet whenever a changed in a particular column. But The change should happen with a formula. But, it is not working. example : When I change A1 to "ok" manually the OnEdit function work, but when the A1 cell change through an If condition to "ok" it's not moving and there is no movement. Can you help me work the Onedit function without a human interfere? 回答1: Issue: As you can see in the official documentation: onEdit(e) runs when a user

Change the line height of all content in a Google doc using the API via nodejs using batchupdate()

夙愿已清 提交于 2021-01-29 19:32:29
问题 Using Method: documents.get I can retrieve a document. The result is structured as described at Resource: documents. However, I need to select the whole document and change the line-height to 1.5, but I am unable to find a way to do it. var updateObject = { documentId: documentId, resource: { requests: [{ 'updateTextStyle': { 'range': { 'startIndex': 1, 'endIndex': 0 }, 'textStyle': { 'line-height': 1.5 }, 'fields': 'line-height' } }], }, }; docs.documents.batchUpdate(updateObject) .then

Saving Sheet to PDF

假装没事ソ 提交于 2021-01-29 19:08:34
问题 Hi all I'm relatively new to scripting. I have some code to convert a google sheet to pdf and email out as an attachment however I am struggling with setting the PDF output page setup. The margins are to big. /* Email Google Spreadsheet as PDF */ function emailGoogleSpreadsheetAsPDF() { // Send the PDF of the spreadsheet to this email address var email = "dav..........n@.....a.com"; // Get the currently active spreadsheet URL (link) var ss = SpreadsheetApp.getActiveSpreadsheet(); // Subject

What is InputMediaPhoto and how to send an array of such resources to Telegram API?

被刻印的时光 ゝ 提交于 2021-01-29 19:05:34
问题 I'm trying some Google Apps Script script for telegram bot API. var token = "BOT:TOKEN"; var telegramUrl = "https://api.telegram.org/bot" + token; var chat_id = "CHAT_ID"; var image1 = "https://telegram.org/img/t_logo.png"; var image2 = "https://www.gstatic.com/images/branding/product/2x/apps_script_48dp.png"; var data = { method: "post", payload: { "method": "sendMediaGroup", "chat_id": chat_id, "media": [ {"type": "photo", "media": image1}, {"type": "photo", "media": image2}, ] } }

ImportXML not producing correct values

吃可爱长大的小学妹 提交于 2021-01-29 19:01:34
问题 I am following the following tutorial to import stock options data into a Google sheet. https://www.youtube.com/watch?v=Be7z9YeeVY0&ab_channel=daneshj The following formula will import data from yahoo finance into the sheet: =iferror(TRANSPOSE(IMPORTXML(CONCATENATE("https://finance.yahoo.com/quote/",A2,"?p=",A2),"//tr")),"You have to add a contract name in column A") At first glance, everything looks fine, as it seems to be pulling data back from the webpage; however, all the values are