Google apps script 使用列范围中的唯一值

Google apps script 使用列范围中的唯一值,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我制作了一个脚本,在这些特定文件夹中创建文件夹和文件。 脚本运行得很好,但我不能使用列范围中的唯一值(文件夹和文件获取所有范围的名称-用coma分隔)-我需要范围中的A1值是第一个文件夹的名称(及其文件的相同名称),A2值是第二个文件夹(及其文件)的名称,等等 我能做些什么来解决这个问题 function myFunction() { var aa = SpreadsheetApp.getActiveSheet(); var data = aa.getDataRange(

我制作了一个脚本,在这些特定文件夹中创建文件夹和文件。 脚本运行得很好,但我不能使用列范围中的唯一值(文件夹和文件获取所有范围的名称-用coma分隔)-我需要范围中的
A1
值是第一个文件夹的名称(及其文件的相同名称),
A2
值是第二个文件夹(及其文件)的名称,等等

我能做些什么来解决这个问题

function myFunction() {    
    var aa = SpreadsheetApp.getActiveSheet();
    var data = aa.getDataRange().getValues();

    var pasta = DriveApp.createFolder(data);
    DriveApp.getFolderById('0B1B9ZGsFr8j0RW82NTRQejd5bmM').addFolder( pasta );
    DriveApp.getRootFolder().removeFolder(pasta);

    var doc = DocumentApp.create(data);
    docFile = DriveApp.getFileById( doc.getId() );
    DriveApp.getFolderById( pasta.getId() ).addFile( docFile );
    DriveApp.getRootFolder().removeFile(docFile);

    docsheet = DriveApp.getFileById('1zSpgQv5u9kvTu9H9kCwh9yUTUgtJ8x9fJLke7_VDCws');
    var dodo = docsheet.makeCopy().setName(data);
    DriveApp.getFolderById( pasta.getId() ).addFile( dodo );
    DriveApp.getRootFolder().removeFile(dodo);
}

你可能想做一些类似于

函数myFunction(){
var aa=SpreadsheetApp.getActiveSheet();
var data=aa.getDataRange().getValues();
map(函数(行){//只获取列A
返回行[0];
}).filter(函数(x,i,s){//如果索引较小,则我们有一个副本
返回s.indexOf(x)==i;
}).forEach(函数(名称){
//创建文件夹
var=DriveApp.createFolder(名称);
DriveApp.getFolderById('0B1B9ZGsFr8j0RW82NTRQejd5bmM').addFolder(意大利面);
DriveApp.getRootFolder().removeFolder(意大利面);
//创建单据var doc=DocumentApp.Create(名称);
docFile=DriveApp.getFileById(doc.getId());
DriveApp.getFolderById(意大利面.getId()).addFile(docFile);
DriveApp.getRootFolder().removeFile(docFile);
//复印单据
docsheet=DriveApp.getFileById('1zspgqv5u9kvtu9h9kch9yutugtj8x9fjlke7_VDCws');
var dodo=docsheet.makeCopy().setName(name);
DriveApp.getFolderById(意大利面.getId()).addFile(dodo);
DriveApp.getRootFolder().removeFile(dodo);
});    
}