【问题标题】:Is it possible to join or bind data together in google sheets?是否可以在谷歌表格中加入或绑定数据?
【发布时间】:2017-06-01 16:50:11
【问题描述】:

我正在寻找一种在 Google 表格中完成数据绑定(连接数据)的方法。

我有两张纸(A = 表格回复,B = 带备注的报告)。我需要将 sheetA 中的数据移动到 sheetB 中。 SheetB 需要将 sheetA 中导入的数据与 sheetB 中手动输入的数据绑定(连接)。

SheetA = 来自回复

(A)Date     (B)Fname     (C)Lname     (D)ID#
1-2-17      Tod          Smith        123456
1-3-17      Jen          Jones        234567
1-5-17      Bob          Craft        345678

SheetB = 带注释的报告 - 按时间倒序排列

(A)Date     (B)Fname     (C)Lname     (D)ID#        (E)Notes
1-5-17      Bob          Craft        345678        Good kid
1-2-17      Tod          Smith        123456        Always late
1-3-17      Jen          Jones        234567        Very helpful

当新记录提交到 sheetA 并导入到 sheetB 中时,我需要“notes”列数据绑定到 A-D 列中的数据,列 (E)Notes 中的数据向下移动并与学生数据保持正确对齐.

SheetB = 带注释的报告 提交新记录时的当前结果

    (A)Date     (B)Fname     (C)Lname     (D)ID#        (E)Notes
    1-7-17      New          Kid          456789        Good kid    
    1-5-17      Bob          Craft        345678        Always late
    1-2-17      Tod          Smith        123456        Very helpful
    1-3-17      Jen          Jones        234567        

您会看到新的学生信息被导入到 sheetB 中,但 (E)Notes 中的笔记与他们的学生没有正确对齐。

SheetB = 带注释的报告 提交新记录时的期望结果

    (A)Date     (B)Fname     (C)Lname     (D)ID#        (E)Notes
    1-7-17      New          Kid          456789            
    1-5-17      Bob          Craft        345678        Good kid
    1-2-17      Tod          Smith        123456        Always late
    1-3-17      Jen          Jones        234567        Very helpful

您会看到新的学生信息被导入到 sheetB 中,并且它已自动向下“移动”一行,因此它与相应的学生保持正确对齐。

【问题讨论】:

  • 我投票决定将此问题作为离题结束,因为它被交叉发布到 Web 应用程序,并且不鼓励在 Stack Exchange 上交叉发布。

标签: function google-apps-script google-sheets formulas


【解决方案1】:

这并不完全是您想要的,但它是一个脚本,它将电子表格中的所有其他工作表组合到一个名为 combinesheets 的工作表中。

function combinesheets()
{
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var allsheets = ss.getSheets(); 
 var combineSht = ss.getSheetByName("combinesheets"); 
 for (var i=0; i<allsheets.length; i++) 
 {
   if (shtName != 'combinesheets')
   {
     var shtName = allsheets[i].getName();
     var sht = ss.getSheetByName(shtName);
     var shtrng = sht.getDataRange();
     var shtrngA = shtrng.getValues(); 
     for(var j=0;j<shtrngA.length;j++)
     {
       combineSht.appendRow(shtrngA[j]);
     }
   }
 }
 SpreadsheetApp.flush();
}

所以也许这会给您一个开始,我们也许可以将其修改为适合您需要的东西。

【讨论】:

  • 感谢您的意见。我确实看到了这个解决方案的价值,但我的项目只有 2 张。
  • 好的,然后将 'combinesheets' 更改为您要与之连接的工作表的名称。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多