简体   繁体   English

当我有多张图纸时,为什么getActiveCell停止工作?

[英]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.

相关问题 删除静音后,为什么我的自动播放停止工作? - Why does my autoplay stop working when I remove mute? 当我的表单中有 onsubmit 事件时,为什么我的 HTML 表单不能正确地将用户输入发送到 Google 表格? - Why does my HTML form not send user input to Google Sheets properly when I have an onsubmit event in my form? 为什么当我使用JQuery DatePicker时Google Code Prettifier停止工作(反之亦然) - Why does Google Code Prettifier stop working when I use JQuery DatePicker (or vice versa) 为什么当我尝试使用 props 传递的函数时 preventDefault 停止工作? - Why does preventDefault stop working when I try to use a function passed by props? 当我告诉AngularJS $ scope.watch()观看数组时,为什么它停止工作? - Why does AngularJS $scope.watch() stop working when I tell it to watch an Array? 为什么这个函数在ajax调用后执行时停止工作? - Why does this function stop working when executed after an ajax call? 在Chrome中打开开发者控制台后,onmouseover为什么会停止工作? - When the developer console is open in chrome, why does onmouseover stop working? 为什么我的 barbajs 转换在与 parcel 捆绑在一起时停止工作? - Why does my barbajs transitions stop working when bundled with parcel? 为什么在useEffect中设置state时POST停止工作? - Why does the POST stop working when setting state in useEffect? 如果我添加一个变量,为什么我的程序停止工作? - Why does my program stop working if I add a variable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM