简体   繁体   English

添加按钮以更新Google Spreadsheet。 递增单元格并用当前日期更新另一个单元格

[英]Add button to update Google Spreadsheet. Increment cell and update another cell with current date

We have spreadsheet that has a list of members at our gym facility. 我们有一个电子表格,其中包含我们健身房设施中的成员列表。 What we would like to incorporate is a way that a coach could walk around with an iPad and click a button that would "check-in" our members. 我们希望采用的一种方法是,教练可以带着iPad走来走去,然后单击“签到”我们的会员的按钮。 Usually the number of members present is small - maybe 20-30 members per class. 通常,出席的成员人数很少-每个班级可能只有20-30名成员。 But, we want a way to try to have coach accountability so if someone doesn't show up for 3 weeks, we can reach out in an email to inquire where they have been. 但是,我们希望有一种方法来尝试对教练负责,因此,如果某人没有出现3个星期,我们可以通过电子邮件与他们联系,询问他们去过的地方。

I've created a test spreadsheet that should be editable. 我已经创建了一个可编辑的测试电子表格。 I need some help with recommendations or writing a script that would perform the following: 我需要一些建议或编写脚本来执行以下操作:

What I would like is a button in the far left "check-in" column next to every member name that our coaches could click when they are present. 我想在最左边的“签到”列中有一个按钮,旁边有我们的教练在场时可以点击的每个会员名称。 What that would do would add +1 to the "total check-ins" column and also update the "last time checked-in" column with the current date/time stamp. 这样做会在“总签到”列中添加+1,并使用当前日期/时间戳更新“上次签到时间”列。

https://docs.google.com/spreadsheet/ccc?key=0AnGxNda7E77DdHZldlhQY2hZZlNJamZ6VTZ0WUhqZXc&usp=sharing https://docs.google.com/spreadsheet/ccc?key=0AnGxNda7E77DdHZldlhQY2hZZlNJamZ6VTZ0WUhqZXc&usp=sharing

I'm brand new to scripting in Google Docs, so thanks in advance for any expertise that is offered! 我是Google文档中脚本编制的新手,所以在此先感谢您提供的任何专业知识! MUCH appreciated! 非常感激!

Here you go 干得好

Spreadsheet https://docs.google.com/spreadsheet/ccc?key=0AvmOEVr803HMdDE5MmZXMlQ1cnpzQ21wYkNNZ19ENXc#gid=0 电子表格https://docs.google.com/spreadsheet/ccc?key=0AvmOEVr803HMdDE5MmZXMlQ1cnpzQ21wYkNNZ19ENXc#gid=0

Script UI (Open this url from any device like Serge said.) https://script.google.com/macros/s/AKfycbxfqII2qhtctJTO1nVyLOBZJ4KxElVh8I3fTCFUR1o5R1uOUcA/exec 脚本用户界面(从Serge所说的任何设备打开此URL。) https://script.google.com/macros/s/AKfycbxfqII2qhtctJTO1nVyLOBZJ4KxElVh8I3fTCFUR1o5R1uOUcA/exec

Code: 码:

function doGet() {
  var ss = SpreadsheetApp.openById('0AvmOEVr803HMdDE5MmZXMlQ1cnpzQ21wYkNNZ19ENXc');
  var sheet = ss.getSheetByName('members');
  var members = sheet.getRange(2, 1, sheet.getLastRow()-1, 1).getValues();
  Logger.log(members)


  var app = UiApp.createApplication().setTitle('Gym Check In');
  var grid = app.createFlexTable().setId('grid');
  app.add(grid);

  var row = 0;
  var column = 0;

  for (var m in members) {    

    grid.setWidget(row, 0, app.createLabel(members[m]));
    grid.setWidget(row, 1, app.createButton('Check In').setId(row+2).addClickHandler(app.createServerHandler('checkIn').addCallbackElement(grid)).addClickHandler(app.createClientHandler().forEventSource().setEnabled(false)));
    row++;
  }
  return app;
}

function checkIn(e) {
  var ss = SpreadsheetApp.openById('0AvmOEVr803HMdDE5MmZXMlQ1cnpzQ21wYkNNZ19ENXc');
  var sheet = ss.getSheetByName('members');

  var button = e.parameter.source;

  sheet.getRange(button, 2).setValue(new Date());  
}

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

相关问题 如何制作一个按钮以跳到Google Spreadsheet中另一个工作表中的特定单元格? - How to make a button to jump to a specific cell in another sheet in Google Spreadsheet? Google表格:单击按钮取消突出显示行,突出显示下一行,并单击日期和时间按钮更新单元格 - Google Sheets: Click button to unhighlight row, highlight the next row, and update cell with date and time button was clicked 如何在 VBA Excel 中添加将当前日期和时间添加到单元格的按钮? - How to add button that adds current date and time to the cell in VBA Excel? 仅通过按钮输入数据/更新单元格 - Enter data in / update cell by button only 使用链接到脚本的按钮时,选定的单元格不会更新 - Selected cell does not update when using button linked to script Excel VBA - 根据对相邻单元格的更新更改按钮可见性 - Excel VBA - Change button visibility based on update to adjacent cell 更新自定义UITableView单元格中的标签 - Update label in custom UITableView Cell 以编程方式将按钮添加到 uitableview 单元 - Add button to uitableview cell programmatically 通过表格单元格按钮将单元格名称传递到另一个视图 - Passing name of cell to another view via table cell button 获取 tableview 单元格按钮以添加新的 tableview 单元格 - get tableview cell button to add a new tableview cell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM