How to copy a table from a website to Excel or Google Sheets
Five ways to get an HTML table from a web page into Excel or Google Sheets, and which one to use when.
| Method | Best for | Fails on |
|---|---|---|
| 1. Select, copy, paste | One small, simple table | Merged cells, links, big tables, pages that block selection |
| 2. Excel: Data → From Web | Public pages you want to refresh later (Excel for Windows) | Tables built by JavaScript, pages behind a login |
| 3. Google Sheets: IMPORTHTML | Public pages, auto-updating sheets | Tables built by JavaScript, pages behind a login |
| 4. A browser extension | Any table you can see, including logged-in and JavaScript pages | Tables inside cross-origin frames |
5. Python pandas.read_html | Many pages, repeatable scripts | Same as 2 and 3 |
1. Select, copy and paste
Drag from the first cell to the last, press Ctrl+C (⌘+C on a Mac), click a cell in Excel or Google Sheets and press Ctrl+V. If the page's fonts and colors come along, paste with Ctrl+Shift+V (values only in Google Sheets) or use Paste Special → Text in Excel.
When it goes wrong: everything lands in one column, merged header cells shift the columns, or the selection also grabs menus and ads. Then use one of the methods below.
2. Excel: Data → From Web (Power Query)
- In Excel for Windows (Microsoft 365, 2016 or later) open Data → From Web (in some versions: Get Data → From Other Sources → From Web).
- Paste the page URL and confirm.
- The Navigator lists every table it found (Table 0, Table 1 …). Pick one, check the preview and click Load.
The query remembers the URL: Data → Refresh All pulls the latest version later. It only sees the HTML the server sends, so tables that the page builds with JavaScript after loading, or pages that need you to log in, usually come back empty.
3. Google Sheets: IMPORTHTML
Type this into a cell, with the page URL and the table's position on the page (1 = first table):
=IMPORTHTML("https://en.wikipedia.org/wiki/List_of_largest_cities", "table", 2)
The number counts every <table> in the page's HTML, including invisible layout tables and sidebars. On that page table 1 is the sidebar, so the city list is table 2. If you get the wrong table, try the next number. The sheet re-fetches the page from time to time, so it stays current. Same limits as Excel: public pages and server-rendered tables only. "list" instead of "table" imports a bulleted or numbered list.
4. A browser extension (works on any table you can see)
An extension reads the table from the page as your browser shows it, so it also works behind a login and on pages that build their tables with JavaScript. PlainTables (ours, free) lists every table on the page; click one to copy it as TSV (pastes straight into cells), Markdown or CSV, or download CSV or Excel (.xlsx). Merged cells are expanded so columns stay aligned, and it only reads a page when you click its button.
5. Python: pandas.read_html
import io, urllib.request
import pandas as pd
url = "https://en.wikipedia.org/wiki/List_of_largest_cities"
req = urllib.request.Request(url, headers={"User-Agent": "table-export-script/1.0 (you@example.com)"})
html = urllib.request.urlopen(req).read().decode("utf-8")
tables = pd.read_html(io.StringIO(html), match="Urban area") # needs lxml
tables[0].to_excel("cities.xlsx") # needs openpyxl
match= keeps only tables that contain that text; without it, tables[0] is often a sidebar or navigation box. Many sites, Wikipedia included, reject Python's default user agent (HTTP 403), which is why the example sets its own. Tables with a two-row header become multi-level columns, which to_excel can only write with the index column kept. It reads the server's HTML, so the JavaScript and login limits of methods 2 and 3 apply here too.
Already have the HTML?
Paste it into the free HTML table to CSV / Excel converter: it runs in your browser and handles colspan and rowspan.
Building the page yourself? See how to add an "Export to Excel" button with JavaScript.
Frequently asked questions
Why does my pasted table end up in one column?
The page's table is often built from div elements rather than a real HTML table, or the paste came in as plain text. Try Paste Special → Text with Tab as the delimiter, or use an extension or IMPORTHTML, which read real table structure.
Why does From Web or IMPORTHTML find no table?
The table is probably added by JavaScript after the page loads, or the page needs a login. Both tools only read the HTML the server sends. A browser extension reads the page as you see it.
How do I copy a Wikipedia table to Excel?
Wikipedia tables are plain HTML, so every method works. IMPORTHTML in Google Sheets or Excel's From Web is quickest. Footnote markers like [1] come along; remove them with Find & Replace.
Can I export a table to Google Sheets without copy-paste?
Yes: IMPORTHTML for public pages. For other pages, copy the table as TSV with an extension and paste it into the first cell.
Written with AI assistance. The pandas example was run against the page shown, and the IMPORTHTML table number was checked against that page's HTML. PlainTables is our extension; the other methods are free and built into Excel, Google Sheets and pandas.