簡體   English   中英

Google 腳本創建新的工作表文件並將其移動到特定文件夾然后將活動工作表中的內容和 2 個標簽復制到新創建的文件

[英]Google script Create new sheet file and move it to a specific folder Then copy the contents and 2 tabs from the active sheet to the newly created file

歡迎:一開始就不深入代碼了,想請教幾個問題。 學習操作邏輯。

問題 1:

當我使用該函數創建一個新文件時

var newFile = SpreadsheetApp.create("Name new sheets")
var newFileId = newFile.getId()

新文件總是保存在google磁盤的根目錄下?

問題2

如果我總是寫谷歌磁盤的根目錄。移動新創建的文件的唯一方法是使用

var TARGE_FOLDER_ID = "asdFHd4hasdasn6nJMGLSQt8das331"
DriveApp.getFileById(newFileId).makeCopy("Name new sheets",TARGE_FOLDER_ID);

在從主 google 驅動器文件夾復制刪除后?

當我使用該函數創建一個新文件時

SpreadsheetApp.create("Name new sheets")將文件放在根目錄中,您必須移動它們

如果我總是寫谷歌磁盤的根目錄。移動新創建的文件的唯一方法是使用

是的,像這樣的移動文件

var folder=DriveApp.getFoldersByName(folderName).next();//gets first folder with the given foldername
var file=SpreadsheetApp.create(fileName);
var copyFile=DriveApp.getFileById(file.getId());
folder.addFile(copyFile);
DriveApp.getRootFolder().removeFile(copyFile);

暫無
暫無

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

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