这就是我想要完成的事情:
这是我到目前为止所拥有的:
function testplan() {
var mainsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
var testplan = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("TestPlan");
var socialData = mainsheet.getRange(3, 3).getValues();
var socialDataText = socialData.length;
var fbSocial = "Facebook";
var twitSocial = "Twitter";
for (var i = 0; i < socialDataText; i++) {
if (socialData[i][0] == fbSocial) {
testplan.getRange("A15").setValue("User can log into the app with Facebook.");
testplan.getRange("A16").setValue("User can share content from the app with Facebook.");
} {
return 0;
};
};
for (var i = 0; i < socialDataText; i++) {
if (socialData[i][0] == twitSocial) {;
testplan.getRange("A17").setValue("User can log into the app with Twitter.");
testplan.getRange("A18").setValue("User can share content from the app with Twitter.");
} {
return 0;
};
};
寻找“Facebook”的第一个命令有效,因为它是第一个文本。但是之后的任何事情都无法找到。我经常搜索并发现了很接近的东西,但是没有任何东西能像我期待的那样发挥作用。这可能是一个命令,或者我没有看到的非常明显的事情。
答案 0 :(得分:0)
试
function testplan() {
var mainsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
var testplan = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("TestPlan");
var socialData = mainsheet.getRange(3, 3).getValues();
var socialDataText = socialData.length;
var fbSocial = "Facebook";
var twitSocial = "Twitter";
for (var i = 0; i < socialDataText; i++) {
if (socialData[i][0].indexOf(fbSocial) > -1) {
testplan.getRange("A15").setValue("User can log into the app with Facebook.");
testplan.getRange("A16").setValue("User can share content from the app with Facebook.");
};
if (socialData[i][0].indexOf(twitSocial) > -1) {;
testplan.getRange("A17").setValue("User can log into the app with Twitter.");
testplan.getRange("A18").setValue("User can share content from the app with Twitter.");
};
};
};
为简单起见