2017-07-17 5 views

答えて

0

otOInkInitを使用して、PropertiesServiceの初期値を設定します。次に、loadSerialをダウンロードスクリプトに入れることができます。

function onOpen(e) 
{ 
    SpreadsheetApp.getUi().createMenu('My Tools') 
    .addItem('otOInk','otOInk') 
    .addItem('otOInkInit', 'otOInkInit') 
    .addItem('loadSerial', 'loadSerial') 
    .addToUi(); 
} 

//provides an otOInk number and increments to the next one 
function otOInk() 
{ 
    var num=PropertiesService.getScriptProperties().getProperty('otOInk'); 
    if(num) 
    { 
    PropertiesService.getScriptProperties().setProperty('otOInk',Number(num)+1); 
    return num; 
    } 
} 
//use to setup the otOInk property in the PropertiesService 
function otOInkInit(initialValue) 
{ 
    var initialValue=(typeof(initialValue)!='undefined')?initialValue:0; 
    PropertiesService.getScriptProperties().setProperty('otOInk',initialValue); 
} 
//loads the otOInk number into a cell of a named sheet 
function loadSerial(cellA1Notation,sheetName) 
{ 
    var cellA1Notation=(typeof(cellA1Notation)!='undefined')?cellA1Notation:'A1'; 
    var sheetName=(typeof(sheetName)!='undefined')?sheetName:'Sheet1'; 
    var ss=SpreadsheetApp.getActiveSpreadsheet(); 
    var sht=ss.getSheetByName(sheetName); 
    var cell=sht.getRange(cellA1Notation); 
    cell.setValue(otOInk()); 
} 
関連する問題