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.
- interrogation – this will be either “list” or “table” depending upon which HTML structure contains the data we are trying to import.
- index – 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.
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 interrogation parameter and 2 for les index paramètre.
Nous nous assurons que le 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.
Pendant que l'importation des données est en cours, la cellule B3 semble contenir une valeur d'erreur. Notez un petit triangle rouge dans le coin supérieur droit de la cellule. Cependant, il ne s'agit pas d'une erreur réelle, mais d'un état transitoire. Pour confirmer, nous pouvons survoler la cellule B3 avec la souris pour voir la description comme indiqué ci-dessous.
Une fois que Google Sheets a chargé les données, le triangle rouge de la cellule B3 disparaît. Nous remarquerons que les données s'étendent de la cellule B3 vers la droite et également plus loin vers le bas.
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.
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.

