簡體   English   中英

Google Script:如何將控制台中的輸出粘貼到 Google 表格中?

[英]Google Script: How do I get my output in the console pasted in google sheets?

這是我當前的代碼:


function myFunction() {
  var sheet = SpreadsheetApp.getActiveSheet();
     sheet.appendRow(["Remove_Later", "Name", "Client", "Name of project", "Deliverables"]); //writes the headers
  var topFolder = DriveApp.getFolderById("ThisIsTheFolderId");
  var topPath = "/";
  iterateSubFolders(topFolder, topPath);
}

function iterateSubFolders(callingFolder, callingPath) {

  var callingFolderName = callingFolder.getName();
  var callingFolderFullPath = callingPath + callingFolderName + "/";
  Logger.log(callingFolderFullPath);

  var childSubFolders = callingFolder.getFolders();
  while (childSubFolders.hasNext()) {
      var nextSubFolder = childSubFolders.next();
      iterateSubFolders(nextSubFolder, callingFolderFullPath);
  }
}

我無法在我想要的谷歌表中獲得控制台輸出。 我不知道,現在已經掙扎了幾個小時。 非常感謝幫助! 先感謝您 :)

您可以將控制台輸出返回到myFunction並將其傳遞給sheet.appendRow

樣本:

function myFunction() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var topFolder = DriveApp.getFolderById("ThisIsTheFolderId");
  var topPath = "/";
  iterateSubFolders(topFolder, topPath);
  sheet.appendRow(["Remove_Later", "Name", "Client", "Name of project", "Deliverables", callingFolderFullPath]); //writes the headers
}

function iterateSubFolders(callingFolder, callingPath) {

  var callingFolderName = callingFolder.getName();
  var callingFolderFullPath = callingPath + callingFolderName + "/";
  sheet.appendRow([callingFolderFullPath]);
  var childSubFolders = callingFolder.getFolders();
  while (childSubFolders.hasNext()) {
      var nextSubFolder = childSubFolders.next();
      iterateSubFolders(nextSubFolder, callingFolderFullPath);
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM