[英]Google Apps Script: How do I pull data entered today from one spreadsheet and transpose it to another?
Okay, I've been working on this for about a month. 好的,我已经为此工作了大约一个月。 I've tried numerous different ways of doing this, and I think I'm close.
我尝试了许多不同的方法来完成此操作,但我想我已经接近了。 I'm not an expert, but here is what I'm trying to do.
我不是专家,但这是我想要做的。 I've created a form that allows me to capture behavior data for my son.
我创建了一个表格,使我可以捕获儿子的行为数据。 (He's autistic, which is why this is important.) I can get the data from the form into a results spreadsheet and I can transfer the data to a new report style pre formatted spreadsheet.
(他是自闭症的,所以这很重要。)我可以将表单中的数据获取到结果电子表格中,然后可以将数据传输到预先格式化的新报表样式电子表格中。 What I can't do is filter the dates effectively.
我不能做的是有效地过滤日期。 My script is below.
我的脚本在下面。
function onOpen() {
var rawdata=SpreadsheetApp.openById("0AtkuL_H_DshvdFU5U1dBLVI1NWhlWXdSNjBXOHdIaUE");
var sheet1=rawdata.getSheetByName("FormResponses");
var maxrows=sheet1.getMaxRows();
var lastcol = sheet.getLastColumn();
var vals=sheet1.getRange(1,1,maxrows,1).getValues();
var date = new Date();
var newDate = date.setDate(date.getDate()+1);
var Sdate=Utilities.formatDate(date,"GMT-0400","yyyy:MM:dd");
var newerDate=Utilities.formatDate(newDate,"GMT-0400","yyyy:MM:dd");
var filter=ArrayLib.filterByDate(vals,1,Sdate,newerDate);
var range1 = sheet1.getRange(1,1,filter,lastcol);
var values = range1.getValues();
var target = SpreadsheetApp.openById("0AtkuL_H_DshvdGxWNGJ0ZjA2VU5zV01iaVNacDZQYWc")
var sheet2 = target.getSheetByName("Sheet1");
var range2 = sheet2.getRange(4,1,i,7);
SpreadsheetApp.setActiveSpreadsheet(rawdata);
values
SpreadsheetApp.setActiveSpreadsheet(target);
range2.setValues(values);
}
//for (var i = 0; i < maxrows; i++) if (Date.parse(vals[i]).valueOf() >= todaydt.valueOf() );
The last line is a prior way I tried to filter the dates. 最后一行是我尝试过滤日期的先前方法。 That's the part I can't quite get to work.
那是我无法完全工作的部分。 Part of my challenge is that I don't quite understand the "for" command yet.
我面临的挑战之一是我还不太了解“ for”命令。 I'm doing the CodeAcademy java course, but since I work, have a family, and don't do this for a living its slow going.
我正在上CodeAcademy Java课程,但是自从我工作以来,有一个家庭,不要为了生计缓慢而这样做。 I've searched about a thousand websites and tried numerous ways to filter the dates, but I can't get any of them to work.
我已经搜索了大约一千个网站,并尝试了多种方法来过滤日期,但是我无法使用它们。 Any help is appreciated.
任何帮助表示赞赏。
I assume arraylib.filterbydate takes dates but you are passing strings. 我假设arraylib.filterbydate需要日期,但是您正在传递字符串。 Try passing dates.
尝试传递日期。 Or just filter by string if that lib allows it.
或者,只要该lib允许,就按字符串过滤。 Since you are formatting the date strings as yyyymmdd your string comparisons could work.
由于您将日期字符串格式化为yyyymmdd,因此可以进行字符串比较。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.