insert_value google sheet脚本,将数据插入特定工作表

时间:2018-06-18 22:43:38

标签: javascript android google-sheets

我为我的生活无法弄清楚我做错了什么。 我正在尝试将数据推送到我的电子表格的Sheet2,但数据总是推送到Sheet1。这是我的代码

function insert_value(e) {

var ss = SpreadsheetApp.getActiveSpreadsheet();
var doc     = SpreadsheetApp.openById(SCRIPT_PROP.getProperty("key"));
var sheet   = ss.getSheetByName (ss,sheet2); // select the responses sheet




var uId = e.parameter.uId;
var  uName= e.parameter.uName;
var uId2 = e.parameter.uId2;
var uId3 = e.parameter.uId3;
var uId4 = e.parameter.uId4;
var uImage = e.parameter.uImage;


var dropbox = "USERS IMAGE";
var folder, folders = DriveApp.getFoldersByName(dropbox);

if (folders.hasNext()) {
  folder = folders.next();
} else {
  folder = DriveApp.createFolder(dropbox);
}

var fileName = uId+uName+uId2+uId3+uId4+"profile_pic.jpg";


var contentType = "image/jpg",
    bytes = Utilities.base64Decode(uImage),
    blob = Utilities.newBlob(bytes, contentType,fileName);
    var file = folder.createFile(blob);

     file.setSharing(DriveApp.Access.ANYONE_WITH_LINK,DriveApp.Permission.VIEW);
   var fileId=file.getId();

    var fileUrl = "https://drive.google.com/uc?export=view&id="+fileId;



 sheet.appendRow([uId,uName,uId2,uId3,uId4,fileUrl]);

 return ContentService.createTextOutput("Success").setMimeType(ContentService.MimeType.JAVASCRIPT);

}

任何人都知道我做错了什么?

0 个答案:

没有答案