IMPORTHTML function in Google Sheets
Imports data from a table or list within an HTML page.
=IMPORTHTML(url, query, index)IMPORTHTML syntax and parameters
Three arguments, three required.
- urlstringRequired
The URL of the page to examine, including protocol (e.g. http://). The value for url must either be enclosed in quotation marks or be a reference to a cell containing the appropriate text.
- querystringRequired
Either "list" or "table" depending on what type of structure contains the desired data.
- indexnumberRequired
The index, starting at 1, which identifies which table or list as defined in the HTML source should be returned. The indices for lists and tables are maintained separately, so there may be both a list and a table with index 1 if both types of elements exist on the HTML page.
IMPORTHTML examples
Formulas you'll actually reuse.
The first table on a Wikipedia page:
=IMPORTHTML("https://en.wikipedia.org/wiki/List_of_countries_by_population", "table", 1)The second bulleted list on a page, one item per row:
=IMPORTHTML("https://example.com/pricing", "list", 2)
IMPORTHTML in Excel
No direct equivalent — here's the way around.
Try IMPORTHTML in the playground
Edit the example — nothing to install.
Preloaded with the IMPORTHTML formula from Example 1 — change anything and watch it respond.
IMPORTHTML errors
What they mean — and the fixes.
#N/ANo table or list at that index — count from 1, and remember that pages built with JavaScript may have none in the raw HTML.
Related functions
More ways Google Sheets gets this done.
- ENCODEURLEncodes a string of text for the purpose of using in a URL query. .WebExcel
- HYPERLINKCreates a hyperlink inside a cell.WebExcel
- IMPORTDATAImports data at a given url in .csv (comma-separated value) or .tsv (tab-separated value) format.WebNo Excel equivalent
- IMPORTFEEDImports a RSS or ATOM feed.WebNo Excel equivalent
- IMPORTRANGEImports a range of cells from a specified spreadsheet.WebNo Excel equivalent
- IMPORTXMLImports data from any of various structured data types including XML, HTML, CSV, TSV, and RSS and ATOM XML feeds.WebNo Excel equivalent