[英]Why does getActiveCell stop working when I have multiple sheets?
I am not actually sure whether it is getActiveCell
or something else that is failing, but this is the code I'm having trouble with: 我实际上不确定是
getActiveCell
还是其他失败的东西,但这是我遇到的代码:
var dataSheet = SpreadsheetApp.getActiveSheet();
var program2define = dataSheet.getActiveCell();
var tempContents = program2define.getDisplayValue();
When I have just one sheet, this gets the string in the active cell, no problems. 当我只有一张纸时,这会将字符串存储在活动单元中,没有问题。 When I add another sheet, suddenly it gets an empty string.
当我添加另一张纸时,突然得到一个空字符串。 I've checked and double checked, I've tried using getSheetByName instead of getActiveSheet - same problem.
我已经检查并再次检查,我尝试使用getSheetByName而不是getActiveSheet-同样的问题。 I've tried it in a test sheet with only one cell filled - same problem as soon as I add another sheet.
我已经在仅填充一个单元格的测试表中尝试过-一旦添加另一张表,就会出现相同的问题。
When I searched, I found this but the problem is the same (empty String) even if I make sure every sheet in the spreadsheet has an active cell that is filled. 当我搜索时, 发现了这个问题,但是即使我确保电子表格中的每个工作表都填充了一个活动单元格,问题还是一样的(空字符串)。
Thanks for any tips! 感谢您的提示!
getActiveSheet() gets the active sheet in a spreadsheet and you can only have 1 active sheet at a time, even an active cell. getActiveSheet()获取电子表格中的活动工作表,并且一次只能包含一个活动工作表,即使是活动单元格也是如此。 So it doesn't make sense that you'd apply it in multiple sheets.
因此,将其应用于多张表没有意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.