【问题标题】:Importhtml rename header name Google sheetsImporthtml 重命名标题名称 Google 表格
【发布时间】:2020-10-09 08:06:07
【问题描述】:

我有这个公式

=QUERY({
 IFERROR(QUERY(IMPORTHTML("url1","table",2),"select Col1, Col5,' '
 where Col1 is not null
label ' ''Hour 2'",1), {"",""});
IFERROR(QUERY(IMPORTHTML("url2","table",2),"select Col1, ' ',Col5
 where Col1 is not null offset 1",1), {"",""}) })

自动生成的前两列标题应标记为“公司”、“第 1 小时”

我尝试了标签 Col1 'Company' 或标签 A 'Company' 但都没有奏效。 如何做到这一点?

【问题讨论】:

    标签: google-sheets google-sheets-formula


    【解决方案1】:

    如果我理解,您将加入两个查询 IMPORTHTML 另一个查询。 但是,在第一列中,您选择了 2 列,而在第二列中,您正在获取其他 2 列。

    如果要标记任何列,可以通过在查询内的查询部分执行以下操作来解决此问题:

    select Col1, Col2 where Col1 is not null label Col1 'Company', Col5 'Hour 1'
           ^^^^  ****                        ^^^^^^^^^^^^^^^^^^^^  *************
    

    你的查询可以变成如下:

    {
    IFERROR(QUERY(IMPORTHTML("url1","table",2),"select Col1, Col5,' '
     where Col1 is not null
    label Col1 'Company', Col5 'Hour1', ' ' 'Hour 2'",1), {"",""});
    IFERROR(QUERY(IMPORTHTML("https://en.wikipedia.org/wiki/List_of_countries_by_population_(United_Nations)","table",4),"select Col1, ' ',Col5
     where Col1 is not null offset 1",1), {"",""})
    }
    

    注意:我删除了 query({something; something}),因为它与 {something; something} 的结果相同

    【讨论】:

      猜你喜欢
      • 2019-09-05
      • 2022-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多