google-apps-script - 如何使用 Google App Script 在 google 电子表格上获取毫秒详细信息
问题描述
这是我正在更新谷歌电子表格的应用程序脚本功能。我正在获取由“/”分隔的所有 Html 用户填充数据。我正在从 Html 页面向谷歌电子表格发送响应,并希望获取日期对象的毫秒详细信息,以避免覆盖。
Let's say if multiple people are submitting at once then, I can get only
the last entry because the date object is created with mm/dd/yyyy hh:mm:ss
format and if multiple people are submitting at the same instance of time
like ( 4 people are submitting at 03/03/2020 04:55:55) then I will be
getting the last submitted record and other records will be overwritten by
the last record.
Can anyone of you help me with this? How should I solve this requirement?
请从我正在调用 google app script API 的 HTML 页面中找到我的 javascript 函数,以运行在 app 脚本中编写的函数 userClick。
function sendData(u_wk_Det)
{
google.script.run.withSuccessHandler(function(response)
{console.log(response);})
.withFailureHandler(function(err){console.log(err);})
.userClick(u_wk_Det);
}
/*code shown below is my app script function using which I am updating the google spreadsheets.*/
`function userClick(u_wk_det)
{
Logger.log('table data - ');
var ss =
SpreadsheetApp.openById('sheetid').getSheetByName('Sheet2');
var Srow = 2;
var Lrow = ss.getLastRow();
var Lcol = ss.getLastColumn();
var data = ss.getRange(2, 1, Lrow , Lcol).getValues().filter(function(o)
{return o !=="" });
for(i in data)
{
var j=i;
j++;
j++;
var Crow = data[i];
if (Crow[0]=='')
{
var dt = new Date();
Logger.log(dt);
Logger.log(Crow[0]);
if(u_wk_det!=="")
{
var user_week_details = u_wk_det.split("/");
ss.getRange(j,1).setValue(dt);
ss.getRange(j,2).setValue(user_week_details[0]);
ss.getRange(j,3).setValue(user_week_details[1]);
ss.getRange(j,4).setValue(user_week_details[2]);
}
}
}
}`
解决方案
推荐阅读
- c++ - UWP 应用服务中的多个部分结果
- node.js - 带有异步转换的长对象流过早结束
- python - 在 random.choices() 中使用索引 [0]
- c# - 我正在尝试匹配两个 xml 文件并从第一个文件中获取 xml 节点作为输出 xml
- cypress - 为赛普拉斯设置自定义默认导入路径
- java - 如何在 JpaRepository 中使用升序降序
- php - 使用 PHP 单击返回文件以供下载
- java - Powermock 2.x verifyStatic(System.class) 正在抛出 NotAMockException
- javascript - 动态页面上的“保存 PDF”功能显示多次迭代的结果全部重叠
- python - 尝试在十六进制编码中添加换行符