用大括号加入importxml和importhtml

时间:2019-11-28 05:41:10

标签: arrays google-sheets google-sheets-formula array-formulas google-sheets-importxml

此公式位于A1中:

=
{
{"LINK DA FOTO","LINK DO PERFIL"}
;
{"LINK DA FOTO","LINK DO PERFIL"}
;
ArrayFormula(SEERRO(PROCH(1,{1;IMPORTXML('Time Casa'!B12,"//table[@class='table squad sortable']//td[@class='photo']/a/img/@src | //table[@class='table squad sortable']//td[@class='name large-link']/a/@href")},(LIN($A$1:$A$52)+1)*2-TRANSPOR(sort(LIN($A$1:$A$2)+0,1,0)))))
}

此公式位于C1中:

=
{TRANSPOR(IMPORTXML(
'Time Casa'!B12,"
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th/img/@title | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[6]/span | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[5] | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[3] | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[4] | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[1] | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[2]
"))
;
IMPORTHTML('Time Casa'!B12,"table","1")
}

结果: enter image description here

通过Sheet2中的这种组合,它可以很好地工作,其结果恰好是上图的结果。

=
{
Sheet3!A:B
,
Sheet3!C:S
}

但是当我通过下面相同的公式加入时,它给出了错误并显示↓

  

函数ARRAY_ROW参数2的行长不匹配。预期54   并拥有:39。

=
{
{
{"LINK DA FOTO","LINK DO PERFIL"}
;
{"LINK DA FOTO","LINK DO PERFIL"}
;
ArrayFormula(SEERRO(PROCH(1,{1;IMPORTXML('Time Casa'!B12,"//table[@class='table squad sortable']//td[@class='photo']/a/img/@src | //table[@class='table squad sortable']//td[@class='name large-link']/a/@href")},(LIN($A$1:$A$52)+1)*2-TRANSPOR(sort(LIN($A$1:$A$2)+0,1,0)))))
}
,
{TRANSPOR(IMPORTXML(
'Time Casa'!B12,"
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th/img/@title | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[6]/span | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[5] | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[3] | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[4] | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[1] | 
//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[2]
"))
;
IMPORTHTML('Time Casa'!B12,"table","1")
}
}

我想知道我需要调整什么才能使其正常工作,我尝试使用=FILTER(X,X<>""),但仍然出现相同的错误。
链接到电子表格:
https://docs.google.com/spreadsheets/d/1DNhl5hf5ofST84nawfBF6kuzhn83UMldh1lS20VTJpA/edit?usp=sharing

1 个答案:

答案 0 :(得分:1)

尝试:

={{{"LINK DA FOTO", "LINK DO PERFIL"};
   {"LINK DA FOTO", "LINK DO PERFIL"};
 ARRAYFORMULA(QUERY(IFERROR(HLOOKUP(1, {1; IMPORTXML('Time Casa'!B12, 
 "//table[@class='table squad sortable']//td[@class='photo']/a/img/@src | 
  //table[@class='table squad sortable']//td[@class='name large-link']/a/@href")},
 (ROW($A$1:$A$52)+1)*2-TRANSPOSE(SORT(ROW($A$1:$A$2)+0, 1, 0)))), 
 "where Col1 is not null"))},
 {TRANSPOSE(IMPORTXML('Time Casa'!B12,
 "//*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th/img/@title | 
  //*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[6]/span | 
  //*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[5] | 
  //*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[3] | 
  //*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[4] | 
  //*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[1] | 
  //*[@id='page_team_1_block_team_squad_3-table']/thead/tr/th[2]"));
 IMPORTHTML('Time Casa'!B12, "table", "1")}}

0