Writing to a Google Spreadsheet from Google App Scripts is described here:
https://developers.google.com/apps-script/storing_data_spreadsheets#writing
Which includes details of the setRowsData method.
I was wondering if there was a method for just setting an individual cell in the spreadsheet. I've searching Google and SO, but can't find anything yet. I'm guessing perhaps that setRowsData is the only way to go, but if there's an alternative setCellData call or similar I'd love to hear about it.
Many thanks in advance
p.s. profusely sorry if this isn't the right place to ask, but the Google App Script team is directing all questions to SO
The Range.setValue service to set a value of a cell. The range should be defined to the cell, for instance, the follwing code does it.
var range = SpreadsheetApp.getActiveSheet().getRange("A1");
Related
Does anyone know if there is a way to use the Google Sheets API to get the email address of a people chip? It seems like the only values it will give me are the person's full name as displayed in the cell.
While trying to figure this out I discovered that the name turns into an email address if you use "Format > Clear Formatting". I hoped I could hack this by copying the value into a hidden sheet, clearing the formatting, and then get the email address there. But though Google Apps Script has a function for executing that on a cell, I have found no way to do it with the Sheets API. I tried clearing all the possible formats I could via batchUpdate with an updateCellsRequest but that isn't turning the people chip into an email address.
I'm at the point where if I really want to automate this, I will need to use the scripts API as well, to deploy and execute a tiny Apps Script just to run clearFormat on a cell. I'd like to avoid this much complication, especially since Apps Script doesn't work for service accounts.
As Tanaike mentioned this is not possible at the moment but there is already a feature request in the Google Issue tracker related to adding the people chips to the Sheets API. You can check the request here.
I would suggest posting a comment on it and explain why you are interested in this feature. Or if you think your request has a different approach you can also submit a new feature request for the Sheets API here.
I have a template Google Doc with linked tables and charts that I need to programmatically update so that I can export it as PDF and send by email. I haven't found a way to do that neither with apps script nor google docs api. And I really want to avoid updating the template with static content.
I know this question has been asked before, but never has a positive solution been found.
If this is still not possible, maybe there is a work around? Like a chrome extension you can trigger that can simulate manual update? Or whatever. Doesn't have to be elegant or anything, just has to work somehow.
Thanks a lot for your help.
I have a Google Apps Script that generates a new copy from a template spreadsheet.
However, the default setting of the new copy allows our domain to view it.
I want to set its default permission via app script to RESTRICTED, equivalent to the UI shown below, so that I can only add specific editors or viewers.
I explored setDomainEdit() but the available examples online seem to apply to protected ranges and sheets. I'm not sure if that will address my requirement, but let me know.
Would someone kindly point me in the right direction?
My problem is solved using this line:
newCopy.setSharing(DriveApp.Access.PRIVATE, DriveApp.Permission.NONE);
One thing to note is to put this line at the end of the function, otherwise it does not seem to work at all. I got the idea from this related post.
The Google Apps Script API for Docs has a number of methods defined that work with Named Ranges in Docs. While I am familiar with Named Ranges in Sheets, I cannot find a way to name a range in Docs.
Does anyone know how to name a range using the Docs UI? (obviously one can do so programmatically).
I was wondering about that also, but it looks as if it is not possible to edit or even see named ranges in the docs UI.
Lets hope, this will be changed in the future...
Can we write our front end design and use the google spreadsheet for the back-end for a website?
Thank You
Google Apps Script might also be a good option for you. You can host your code on the Google servers (all written in JavaScript) with easy access to all the spreadsheet and docs APIs. You can see a lot of tutorials on the site.
Another even simpler option might be Google Forms - if you are just trying to gather some data and record it in the spreadsheet.
You have probably already found an answer or a workaround, but here is an example from Google.
https://developers.google.com/apps-script/storing_data_spreadsheets