表单上的Google Apps脚本提交时间格式化毛刺/修复 [英] Google Apps Script on Form Submit Time Formatting Glitch/Fix

查看:162
本文介绍了表单上的Google Apps脚本提交时间格式化毛刺/修复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/ Spreadsheet,但可能是Spreadsheet界面的日期转换实用程序的一部分(并且是预期功能)。



文本框中输入格式在Google表单中,表单提交和响应电子表格之间存在某种通信错误,或者在将表单数据发送到电子表格之前对其进行预处理。只有格式 ### ## TEXT 其中 TEXT 包含的文本字段中的数据出现故障。字符。例如: 4:15 pm 会重现毛刺,但是 4:15 pm 4:15 pm 不会。



结果:撇号字符被添加当它被放到电子表格的时候(例如'4:15 pm ),它会抛出几个使用那个时间数据的子系统。这里有两个截图(对不起,第二个错误的大小):



I 99%肯定这个毛病是由 ##:组合造成的。



临时修正?:真正的问题是...在开始处理时间数据之前,我该如何去除这个讨厌的撇号?我知道如何获得单元格/范围的值()。假设我有以下方式的单元格的值:

  var value = myRange.getValue(); 
// value ='4:15 pm

如何处理该值成 4:15 pm ?一个简单的java函数可以是

pre $ value $ value.substring(1); //假设value是一个字符串

但是在Google App Scripts for Spreadsheets 我不知道该怎么做。



后脚本:这是必要的后处理这个数据我不必在语言系教授大学教师关于正确输入格式的时间格式。



感谢那些可以帮助的人!

解决方案


如何将这个值处理成4:15 pm?一个简单的java
函数可以是

value = value.substring(1); //假设value是一个字符串,但是在
Google App Scripts for Spreadsheets中,我不知道该如何做。


Google Apps脚本使用的Javascript具有完全相同的方法。

  value = value.substring(1); 

应该会返回除第一个字符以外的所有字符。

<有关Javascript子串的更多信息,请访问: http://www.w3schools.com/jsref/jsref_substring.asp


Background:

How: I suspect that this is a glitch within Google Form (submission process)/Spreadsheet, but may be part of the Date conversion utility of the Spreadsheet interface (and is an intended feature).

When entering a format in a text box in Google Forms, there is some sort of communication error between the Form submit and Response Spreadsheet, or pre-processing of the Form's data before it is sent to the spreadsheet. The glitch only seems to happen for data in a text field of the format ##:## TEXT where TEXT contains no '.' characters. For example: 4:15 pm will reproduce the glitch, but 4:15 p.m and 4:15 p.m. will not.

Result: An apostrophe character is added to the beginning of the string when it is put into the Spreadsheet (i.e. '4:15 pm) which throws off several sub-systems I have in place that use that time data. Here are two screenshots (sorry for the bad sizing on the second):

I'm 99% certain that the glitch is caused by the ##: combination.

Temporary Fix?: The real question is... how might I go about removing that pesky apostrophe before I start manipulating the time data? I know how to getValue() of a cell/Range. Assume I have the value of a cell in the following manner:

var value = myRange.getValue();
// value = '4:15 pm

How can I go about processing that value into 4:15 pm? A simple java function could be

value = value.substring(1); // Assuming "value" is a String

But in Google App Scripts for Spreadsheets, I don't know how I would do that.

Post-Script: It is necessary to post-process this data so that I don't have to lecture university faculty in the language department about inputting time format correctly in their forms.

Thanks in advance to those who can help!

解决方案

How can I go about processing that value into 4:15 pm? A simple java function could be

value = value.substring(1); // Assuming "value" is a String But in Google App Scripts for Spreadsheets, I don't know how I would do that.

Google Apps Scripts uses Javascript which has the exact same method.

value = value.substring(1);

should return all except the first character.

More about Javascript substring at: http://www.w3schools.com/jsref/jsref_substring.asp

这篇关于表单上的Google Apps脚本提交时间格式化毛刺/修复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆