【问题标题】:Can you create a Form that reads data from a spreadsheet on Google Docs?您可以创建一个从 Google Docs 上的电子表格中读取数据的表单吗?
【发布时间】:2013-06-13 23:55:44
【问题描述】:

所以我创建了一个表单,它询问一堆一般的联系信息,数据通过 Google Docs 存储在电子表格中。这一切都很好。现在可以创建另一个查询电子表格的表单吗?例如,我希望用户能够在不暴露整个数据库的情况下查询居住在同一区域的所有联系人。这可能吗?

【问题讨论】:

    标签: google-docs google-docs-api


    【解决方案1】:

    一种方法是使用 Google Visualization API 查询语言。这看起来更像是用于购物车而不是数据,但我在网上看到的一些示例似乎像您正在寻找的那样使用它。

    如果您对执行此操作的 3rd 方工具持开放态度。有一个名为 Cloud Snippets 的工具。 (www.cloudwrd.com)。片段使用带有标准 HTML 的标记语言,该语言与 Google 表格交互,允许在数据上创建表单、自定义输出和条件过滤器。

    以下是在联系人表中使用性别过滤器的代码示例:

    <!-- If no search, present a form -->
    <# if ("<#[url.search]#>" == "") { #>
      <form method="GET" action="<#[system.referring_page_url as html]#>">
        <# convert system.referrer to hidden HTML form inputs; #>
        <label >Gender</label>
        <select name="gender">
            <option value="male">Male</option>              
            <option value="female">Female</option>              
        </select>
        <input type="hidden" name="search" value="true" >
        <input type="submit" value="Lookup" />
      </form>
    
    <!-- we have search paramaters - so lets do the query -->
    <# } else { #>
    
    <# start list for googlesheet "Contacts"; 
        // use the "is set" designator for conditional filter passed to a page in the "url" or "post"
        include when gender is "<#[url.gender]#>" if set;
    
    #>
    
    <# start header #>
    <table>
        <tr>
            <th>Gender</th>
            <th>Name</th>
            <th>Address</th>
            <th>Email</th>
        </tr>
    <# end header #>
    
    <# start row #>
        <tr>
            <td><# gender #></td>
            <td><# first #><# last #></td>
            <td><# street #>, <# city #>, <# state #></td>
            <td><# email #></td>
        </tr>
    <# end row #>
    
    <# start footer #>
    </table>
    <# end footer #>
    
    <# no results #>
    No Results
    <# end no results #>
    
    <# end list #>
    
    <# } #>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-20
      相关资源
      最近更新 更多