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.
File.txt :
a1 a2 a3 a4 a5 a6 Code :
awk '{array[NR]=$0} END {for (i in array) {if (i>1) {{print array[i-1]","array[i]}}}}' File.txt Result :
a1,a2 a2,a3 a3,a4 a4,a5 a5,a6 After the all rows are imported to an array, it shows next row to current row under a condition of row > 1.
This is a sample script for retrieving cells without blank cells. Figure 1 shows the sample spreadsheet. In this sheet, the row 14 has one space. Fig. 1: Sample spreadsheet. Data is retrieved as follows.
var data = SpreadsheetApp .getActiveSpreadsheet() .getActiveSheet() .getRange('a1:a30') .getValues(); 1. Retrieving cells with spaces and no blank cells. var Result = [i for each (i in data)if (i)].