var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var chart = sheet.newChart() .setChartType(Charts.ChartType.LINE) .asLineChart() .addRange(sheet.getRange('a1:a21')) .addRange(sheet.getRange('b1:b21')) .addRange(sheet.getRange('c1:c21')) .setColors(["green", "red"]) .setBackgroundColor("black") .setPosition(5, 5, 0, 0) .setPointStyle(Charts.PointStyle.MEDIUM) .setOption('useFirstColumnAsDomain', true) .setOption('height', 280) .setOption('width', 480) .setOption('title', 'Sample chart') .setOption('hAxis', { title: 'x axis', minValue: 0, maxValue: 20, titleTextStyle: { color: '#c0c0c0', fontSize: 20, italic: false, bold: false }, textStyle: { color: '#c0c0c0', fontSize: 12, bold: false, italic: false }, baselineColor: '#c0c0c0', gridlines: { color: '#c0c0c0', count: 4 } }) .
It is necessary to retrieve access token on Google. Scope is as follows.
https://www.googleapis.com/auth/drive Other mimetypes can be seen here.
Download and convert from Spreadsheet to Excel curl -X GET -sSL \ -H "Authorization: Bearer [Your access token]" \ -o "Excel file name" \ "https://www.googleapis.com/drive/v3/files/[File ID]/export?mimeType=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" Upload and convert from Excel to Spreadsheet curl -X POST -sSL \ -H "Authorization: Bearer [Your access token]" \ -F "metadata={ \ name : '[File name on Google Drive]', \ mimeType : 'application/vnd.
This is a Sample Array Script for Spreadsheet. It makes an 2D array filled by strings and number. The strings and number are column strings and row number, respectively.
However, because this is a sample, the maximum column number is 26.
function sa(row, col){ if (col > 26) return; var ar = new Array(row); for(var i = 0; i < row; i++) ar[i] = new Array(col); for (var i = 0; i < row; i++){ for (var j = 0; j < col; j++){ ar[i][j] = String.
About Event Objects For example, it thinks the situation of input text of ’test’ to ‘A1’ on a sheet.
When you use only ‘onEdit(e)’ without an installing trigger, ’e’ has following parameters.
{authMode=LIMITED, range=Range, source=Spreadsheet, user=, value=test} In this case, the event cannot send an e-mail because of ‘authMode=LIMITED’.
When you use “onEdit(e)” with an installing trigger of “Edit”, ’e’ has following parameters.
{authMode=FULL, range=Range, source=Spreadsheet, value=test, triggerUid=#####} In this case, the event can send an e-mail because of ‘authMode=FULL’.
File upload using HTML form in GAS project Rule
Following scripts have to be made into a project of Google Apps Script.
Deploy the GAS project as a web application. Ref
After updated the script, it has to be updated as a new version.
Form.html :
<html> <body> <form> <input type="file" name="imageFile"> <input type="button" value="ok" onclick="google.script.run.upload(this.parentNode)"> </form> </body> </html> GAS :
function doGet() { return HtmlService.