These are the sample scripts by the various languages for requesting to Web Apps created by Google Apps Script.
Inspired by this gist.
- Create a new App Script project.
- Paste the content of the file
google-app-script-crud.gsin the defaultCode.gsfile. - Create a new Spreadsheet.
- Copy the Spreadsheet ID found in the URL into the variable
SHEET_IDlocated in line 1 of your file.
This is for adding the query parameters to the URL. These scripts can be also used for Javascript. When I created an endpoint with some query parameters, I had used the scripts of various patterns every time. Today, I prepared this sample script to unify them. If this is also useful for you, I'm glad.
String.prototype.addQuery = function (obj) {| function exportSpreadsheet() { | |
| //All requests must include id in the path and a format parameter | |
| //https://docs.google.com/spreadsheets/d/{SpreadsheetId}/export | |
| //FORMATS WITH NO ADDITIONAL OPTIONS | |
| //format=xlsx //excel | |
| //format=ods //Open Document Spreadsheet | |
| //format=zip //html zipped | |
| { | |
| "Condition statement": { | |
| "prefix": "cond", | |
| "body": [ | |
| "$1 { $0; break }" | |
| ], | |
| "description": "Switch condition statement" | |
| }, | |
| "Condition single quoted string statement": { | |
| "prefix": "condsqstr", |
| //If the current cell is more than the previous cell, set it as lime green | |
| function onEdit(e) { | |
| var ss = SpreadsheetApp.getActive(); | |
| var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | |
| var name = sheet.getName(); | |
| var range = sheet.getRange("A:J"); | |
| var values = range.getValues(); | |
| var cell = sheet.getActiveCell(); | |
| var value = cell.getValue(); |
This is a helper function that will convert a given PDF file blob into text, as well as offering options to save the original PDF, intermediate Google Doc, and/or final plain text files. Additionally, the language used for Optical Character Recognition (OCR) may be specified, defaulting to 'en' (English).
Note: Updated 12 May 2015 due to deprecation of DocsList. Thanks to Bruce McPherson for the getDriveFolderFromPath() utility.
// Start with a Blob object
var blob = gmailAttchment.getAs(MimeType.PDF);