5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

指定のフォルダにGoogle Spreadsheetを新規作成し,セルに入力するGoogleAppsScript関数

Last updated at Posted at 2017-01-10

Google Spreadsheetを特定のフォルダに新規作成

テンプレート
function main(){
  var ssNew = createSpreadsheetInfolder("**********", "test");//フォルダのIDは別途調べておく
  var ssNewID = ssNew.getId();//IDをゲット
  var ssNewFile = SpreadsheetApp.openById(ssNewID);//オープン
  var activeSpreadsheet = SpreadsheetApp.setActiveSpreadsheet(ssNewFile);//アクティブシートに設定,操作が有効なシート
  var masterSheet  = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];//アクティブシートをゲットする
  setValue(masterSheet, 1, 1, "データ");
  ・・・

}

function createSpreadsheetInfolder(folderID, fileName) {
  var folder = DriveApp.getFolderById(folderID);
  var newSS=SpreadsheetApp.create(fileName);
  var originalFile=DriveApp.getFileById(newSS.getId());
  var copiedFile = originalFile.makeCopy(fileName, folder);
  DriveApp.getRootFolder().removeFile(originalFile);
  return copiedFile;
}

function getValue(sheet,row,col) {//spreadsheetからrow行のcal列のデータをもらってくる関数
  var value = sheet.getRange(row, col).getValue();
  return value;
}

function setValue(sheet,row,col,value){//row行のcal列にデータをセットする関数
  var cell = sheet.getRange(row,col);
  cell.setValue(value);
}

5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?