简体   繁体   English

Google Sheets Apps 脚本,不会注册单元格值

[英]Google Sheets Apps Script, won't register cell value

I have a google sheet that uses an app script button to send the values from that sheet to another sheet.我有一个谷歌表,它使用应用程序脚本按钮将值从该表发送到另一个表。 If someone forgets to press enter after filling in their information, it will not send the last cell value.如果有人在填写信息后忘记按 Enter 键,则不会发送最后一个单元格值。

So if the cell previously had the value of 3, then we change it to 4, but don't press enter, it will send the value of 3.因此,如果单元格之前的值为 3,那么我们将其更改为 4,但不要按 Enter,它将发送值 3。

The solution, I think, is at the beginning of the function for it to submit somehow, or press enter, or select another cell, anything that works.我认为,解决方案是在 function 的开头以某种方式提交,或按 Enter 键,或 select 另一个单元格,任何可行的方法。 But I can't figure out how to do that so far.但到目前为止,我无法弄清楚如何做到这一点。

I've tried various things but I can't find the right apps script function.我尝试了各种方法,但找不到合适的应用程序脚本 function。

So far without pressing enter, or clicking on another cell, I am unable to access that cell value.到目前为止,如果不按 enter 或单击另一个单元格,我就无法访问该单元格的值。 Changing the active selection doesn't work.更改活动选择不起作用。

const sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("L1");

// change the active selection to another cell, but it just moves the 4 to the new cell
sh.setActiveSelection('A1');

In Google Sheets, it's not possible to force the cell edit submission (ak pressing enter) on behalf the active user.在 Google 表格中,无法代表活动用户强制提交单元格编辑(按回车键)。 If training your spreadsheet users doesn't look a good solution, then you should consider another way for data entry, ie make a form in dialog/sidebar so you can use client side HTML/CSS/JavaScript to control your form.如果培训您的电子表格用户看起来不是一个好的解决方案,那么您应该考虑另一种数据输入方式,即在对话框/侧边栏中制作一个表单,以便您可以使用客户端 HTML/CSS/JavaScript 来控制您的表单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM