我是否使用DriveApp或DocList?

时间:2014-05-07 16:25:46

标签: google-apps-script google-drive-api google-spreadsheet-api google-drive-realtime-api

与DocList和DriveApp关联的许多功能看起来都相同。


我打算使用以下代码创建一系列电子表格

  function createSpreadSheet(sheetO,valuesO,rangeN,folderD){
    var ssNew = SpreadsheetApp.create(ssName);//creates a new spreadsheet
    var ssNewKey = ssNew.getId();//captures key of new spreadsheet
    Logger.log('New sheet made with key:'+ssNewKey);//logs the new key
    var file = DriveApp.getFileById(ssNewKey);
    var root = DriveApp.getRootFolder();//all files are created in the 'root folder', they must be have a new directory added and then be removed from the old directory.
    file.addToFolder(folderD);//adds new directory
    file.removeFromFolder(root);//removes file from 'root'
    var sheetN = ssNew.getSheets()[0];//calls first 'sheet1'
    sheetN.getRange(rangeN).setValues(valuesO).setBackgrounds(bkgrndsO);//sets values of cells within rangeN to valuesO
}

我还没有完成构建valuesO和rangeN的结构,但我不确定是否应该为此或DocList使用DriveApp。是否存在会影响我要做的事情的差异?

1 个答案:

答案 0 :(得分:1)

DriveApp较新,如果可能,应该首选。