google-docs-api

How to change only the *selected* text to uppercase, not the entire paragraph in which the selection exists

℡╲_俬逩灬. 提交于 2021-02-08 08:25:23
问题 In Google docs, this function changes the selected text to black function selectedFontColorBlack() { // DocumentApp.getUi().alert('selectedFontColorBlack'); var sel = DocumentApp.getActiveDocument().getSelection(); var elements = sel.getRangeElements(); for (var i = 0; i < elements.length; i++) { var element = elements[i]; // Only modify elements that can be edited as text; skip images and other non-text elements. if(element.getElement().editAsText) { var text = element.getElement()

How to change only the *selected* text to uppercase, not the entire paragraph in which the selection exists

喜欢而已 提交于 2021-02-08 08:24:05
问题 In Google docs, this function changes the selected text to black function selectedFontColorBlack() { // DocumentApp.getUi().alert('selectedFontColorBlack'); var sel = DocumentApp.getActiveDocument().getSelection(); var elements = sel.getRangeElements(); for (var i = 0; i < elements.length; i++) { var element = elements[i]; // Only modify elements that can be edited as text; skip images and other non-text elements. if(element.getElement().editAsText) { var text = element.getElement()

R code on Google docs

烈酒焚心 提交于 2021-02-06 12:44:27
问题 I'm aware that you can publish spreadsheets on Google docs and then import them in R. However, let's say I have a function or some code I want to read in R (like in the source function). How would you for example read in all this code stored on google docs? https://docs.google.com/document/edit?id=1f11rcVs9AtVcgOyiP0lV04yq9hshVDIPx93lA0ItFvQ I don't think this has been published but it's just to give an example. Basically I want to: Create a function in R (for comparability see example below)

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('

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

google docs linked charts refresh with api or apps script

寵の児 提交于 2021-01-29 18:23:37
问题 I have a google doc that I show inside an iframe in my website for public editing , it contains linked charts from a public spreadsheet, I change the chart data with spreadsheet api, but the chart in the doc does not refresh automatically, and I can't clic update or update all in the doc because the " update button " is disabled, SO I wanted to use google docs api or apps script to refresh charts, I did not find how to do it with google docs api , and apps script does not trigger inside the

How to copy image from one table cell to another within google documents using a google script (programmatically)?

痞子三分冷 提交于 2021-01-29 09:49:53
问题 I would like to copy the content of one google doc to another. The content includes text, tables and images. My code copies the text and the tables. However, whatever is contained in table cells is not copied. I made a simplified version of the code and single document accessible here: https://docs.google.com/document/d/1hcQzBuMA6E15u8VtW2lWGL7XCcU3qVsDhn-5jiznQP4/edit?usp=sharing. The code simply copy-pastes the content of the google document which includes a table containing a table/images.

Merge two google documents together using node googleapis

不想你离开。 提交于 2021-01-29 08:41:22
问题 I need to merge two google docs into one. I know how to copy one doc, but I need to create a new document which contains the contents of two google docs. I came up with the following: const auth = await authorize(credentials) const docs = google.docs({version: 'v1', auth}) const drive = google.drive({version: 'v3', auth}) const file1ToCopy = await docs.documents.get({documentId: FILE_1_ID}) const file2ToCopy = await docs.documents.get({documentId: file_2_ID}) const {body: body1ToCopy} =

Empty data cell validation

不羁的心 提交于 2021-01-28 14:19:25
问题 How can I add validation on cell, that checks if the cell is not empty after creating new data record? Something like mandatory fields. 回答1: I think this is not possible (in the way I think you are requesting). From here: If data validation is applied to cells containing data, rules won't be applied until the data is modified. That does not actually say "No, it is not possible" but I think can be inverted as, "No modification, no trigger for validation" - and I'm assuming your cells start off

Downloading a file from Google Drive in Javascript client

雨燕双飞 提交于 2021-01-28 05:28:33
问题 I'm trying to integrate the Google Drive in my angular application So that our users can copy the content from docs and download their images to my application. As per the file:get API Documentation, I'm using the below code to get the file var request = gapi.client.drive.files.get({ 'fileId': fileId }); var temp = this; request.execute(function (resp) { }); But in the response I'm getting only File name and ID.There is no download URL which is required for downloadFile function. Response: