Importar tabelas da Web para o Planilhas Google

We all know how resourceful Google Sheets application has become in our daily life. While it is extremely good with all the basic and advanced spreadsheet needs, it also lets us connect with the outside information with ease. For instance, if we need to import a web HTML table to Google Sheets, it has a native function called as IMPORTHTML formula. Here’s the syntax:

IMPORTHTML(url, query, index)

  • url – this is the address (link/URL) to the HTML page on the web, where the table or list that we are looking to import is located. This can either be a fully qualified URL string like “https://en.wikipedia.org/wiki/Demographics_of_the_world”. Or it can be a reference to a cell (like B1) where the URL is stored.
  • consulta – this will be either “list” or “table” depending upon which HTML structure contains the data we are trying to import.
  • índice – the index number that uniquely identifies the list or table within the HTML page. Please note that the indexes for both lists and tables are treated separately. Both a table and list can exist with the same index number.

39

Automatize as transferências de dados entre planilhas

Saiba como

Example: import a web HTML table to Google Sheets

Please consider the image below. B3 is the cell where we are entering the IMPORTHTML formula. On the web page where the URL (mentioned above) takes us, we are rather interested in the second table. Hence we’re going to use “table” for consulta parameter and 2 for o índice parâmetro.

HTML Table to Google Sheets: IMPORTHTML Formula and Explanation Window

Nós garantimos que a url is within double quotes and hit the Enter key. As soon as we do that, Google Sheets tries to fetch the data. Bigger the table data, the longer it might take to finish the data import.

HTML Table to Google Sheets: Google Sheets Fetching Data

Enquanto a importação de dados está em andamento, a célula B3 parece estar exibindo um valor de erro. Observe um pequeno triângulo vermelho no canto superior direito da célula. No entanto, não é um erro real, mas sim um estado transitório. Para confirmar, podemos posicionar o mouse sobre a célula B3 e ver a descrição, conforme mostrado abaixo.

HTML Table to Google Sheets: Snapshot of Data Loading

Assim que o Google Sheets carregar os dados, o triângulo vermelho na célula B3 desaparecerá. Notaremos que os dados se estendem da célula B3 para a direita e também para baixo.

HTML Table to Google Sheets: Imported Sample Data of Cities and Details

We may not know how far the data is going to extend. So, it is very important that we keep the expected real estate of the result, clear of any preoccupied values. Otherwise, the IMPORTHTML formula will return a #REF! error, as shown in the snapshot below. Please note, for the purposes of demonstration, we entered a dummy value in the cell C9.

HTML Table to Google Sheets: REF Error

Congratulations! We now learned how to import a web HTML table to Google Sheets, by making use of the native IMPORTHTML formula! Go through the following blog post to learn how to import RSS feed to Google Sheets.

39

Automatize as transferências de dados além da Importrange

Saiba como

Você também pode gostar...

Recursos e fórmulas do Google Sheets

As 5 principais fórmulas de matriz dinâmica no Planilhas Google 

O Google Sheets evoluiu para além das planilhas básicas. Com a introdução de fórmulas de matriz dinâmica, os usuários agora podem manipular e analisar...
Recursos e fórmulas do Google Sheets

Dominando a fórmula FILTER: 4 casos de uso com exemplos

A fórmula FILTER do Planilhas Google é uma ferramenta versátil para extrair dados que atendam a condições específicas. Ao contrário da fórmula QUERY,...
Recursos e fórmulas do Google Sheets

Desbloqueando o poder de SUMIF e SUMIFS no Planilhas Google: 4 casos de uso na vida real

As fórmulas SUMIF e SUMIFS no Planilhas Google são ferramentas indispensáveis para realizar somas condicionais. Elas simplificam a...