0

我编写了一个脚本来通过全局变量收集数据:

var row = sheet.getActiveSelection().getRowIndex();
var mfg = sheet.getRange("M" + row).getValue().toUpperCase()
var changeOrder = sheet.getRange("W" + row).getValue().toUpperCase()
var sku = sheet.getRange("H" + row).getValue()
var revision = sheet.getRange("AE" + row).getValue()
var productName = sheet.getRange("J" + row).getValue().toUpperCase()
var packSize = sheet.getRange("K" + row).getValue().toUpperCase()
var project = sheet.getRange("D" + row).getValue().toUpperCase()

var targetSS = SpreadsheetApp.openById('0Ai_j76HcGMnIdG1QNDgxQU1NWWVIQ2o2bkM5SjdtQ0E').getSheetByName('Tech Newsletter - Current');
var targetLastRow = targetSS.getLastRow(); // Get # rows currently in target
var targetNewRow = targetLastRow+1

var nlMfg = targetNewRow.getRange("C").setValue(mfg);

and I want to run a custom script, when the menu option is selected, it will take the global variables and add them in custom order (next available row) to a pre-defined worksheet or another google doc if possible.

另一个工作表称为“时事通讯”,A 列 = 时间戳,B 列 = 用户,C 列 = mfg,D 列 = changeOrder,E 列 = sku,F 列 = productName + packSize,G 列 = 项目

我可以编写一个函数来获取一个文本框,但这没有帮助。我所做的研究只会让我根据标准复制整个范围。没有帮助。我已经有了菜单选项,但需要一个函数来告诉文档将数据放在哪里。

谢谢,

4

2 回答 2

0

请参阅电子表格App.openById(yourid).appendRow

于 2013-10-09T19:31:24.873 回答
0
   var targetSS = SpreadsheetApp.openById('0Ai_j76HcGMnIdFRUUFZIRTdsUmhXdjcxUmtmSlY3Mmc').getSheetByName('Newsletter Template');
  var targetLastRow = targetSS.getLastRow(); // Get # rows currently in target
  var targetNewRow = targetLastRow+1


 targetSS.getRange("A"+targetNewRow).setValue(month + "/" + day + "/" + year);
 targetSS.getRange("B"+targetNewRow).setValue(username)
 targetSS.getRange("C"+targetNewRow).setValue(mfg);
 targetSS.getRange("D"+targetNewRow).setValue(changeOrder);
 targetSS.getRange("E"+targetNewRow).setValue(sku + " REV" + revision);
于 2013-10-10T18:49:16.347 回答