How to Export HTML Tables to Excel? (3 Easy Ways)

Reading time: 4 min read
Muninder Adavelli
Written by
Muninder Adavelli

Updated · Nov 23, 2023

Muninder Adavelli
Digital Growth Strategist | Joined October 2021 | Twitter LinkedIn
Muninder Adavelli

Muninder Adavelli is a core team member and Digital Growth Strategist at Techjury. With a strong bac... | See full bio

Girlie Defensor
Edited by
Girlie Defensor

Editor

Girlie Defensor
Joined June 2023
Girlie Defensor

Girlie is an accomplished writer with an interest in technology and literature. With years of experi... | See full bio

Techjury is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission. Learn more.

Web scrapers commonly target information like prices, forms, calendars, and schedules. However, these data types are often presented on websites using HTML tables.

With its rows and columns, an HTML table makes data easy to understand but challenging to scrape. Fortunately, you can do it in three easy ways. 

Learn how to export HTML tables to Excel and understand the importance of doing so. Read on.

🔑 Key Takeaways

  • Exporting HTML tables to Excel makes it easy to organize and work with tabular data.
  • There are three methods to export HTML tables to Excel. Each has its advantages and requirements.
  • Copy-pasting is the easiest way to export HTML tables, requiring only a browser and Excel for quick data transfer. 
  • The second method simplifies the process by directly importing data into Excel, bypassing the need for a browser. 
  • You can also use JavaScript if you want automation when working with HTML tables for efficient data conversion. 

3 Ways to Export HTML Table Data to Excel

Excel is a powerful tool for analyzing data. Its features allow users to organize and analyze data easily. By exporting HTML tables to Excel, you can make data analysis faster and more efficient. 

You can convert HTML tables to Excel directly in 3 ways. Each of these methods comes with its advantages and requirements:

3 Ways to Export HTML Tables to Excel

1. Copy and Paste Method

The manual copy-paste trick is the simplest method to export HTML tables to Excel. This approach only requires a browser since you only have to copy tables from websites to Excel.

Here are the steps to export HTML tables to Excel by copying and pasting:

Step 1: Go to the website with the table you want to export. Here's sample data from a webpage:

Sample data from a webpage

Step 2: Copy the data you need from the HTML table.

Step 3: Open Microsoft Excel and create a new file.

Step 4: Paste the table where you want it on the cell.

Data pasted in a spreadsheet

Step 5: Adjust the width and height of the columns and rows to fit the data well.

Step 6: Save the sheet as an Excel or CSV file.

💡 Did You Know?

You can also use Excel to organize raw and unstructured data. Excel is a practical tool you should consider using when dealing with basic data sets and want to avoid paying for complex or expensive apps. 

2. Direct Import Method

Another method to import HTML tables into Excel sheets is through  “Get Data From Web.” This feature lets you transfer website data into Excel spreadsheets without a browser.

Here’s how you can export HTML to Excel through Direct Import: 

Step 1: Open Excel and create a new file.

Step 2: In the Data tab, click From Web and select Get Data from External Sources.

Excel Menu bar

Step 3: A pop-up will appear. Enter the URL of the HTML file with the table that you want to export. Click Go.

Excel Web Query Windo

Step 4: On the left side of the screen, select the table you want from the list, then click Transform Data.

Web Query sample from Excel

Step 5: Adjust the rows and columns to ensure everything looks right.

Exported HTML Table Data 

Step 6: Save the file.

3. JavaScript Method

This method uses Javascript to convert an HTML table into an Excel-supported format. Doing so allows you to work on HTML tables and automate data conversion. 

📝 Requirements

You will need a code editor like Visual Studio Code or Sublime Text and a basic understanding of JavaScript and HTML concepts.

Follow these steps to learn how to export HTML tables to Excel using JavaScript:

Step 1: Create an HTML table on the webpage with proper structure.

Step 2: Include the “SheetJS” library with the script tag:

<script src= ‘path/to/xlsx.full.min.js’></script>

Step 3: Write the function to convert and export the table data using “SheetJS.”

function exportToExcel(){

      const table = document.getElementById(‘your-table-id-here’)

      const wb = XLSX.utils.table-to-book(table);

      XLSX.writeFile(wb, ‘data.xlsx’ );

}

Step 4: Add a clickable button to your HTML page.

<button id=’exportBtn’ onClick = “exportToExcel()”> Export Table</button>

Step 5: When you click the button, the script will work on downloading the file.

👍 Helpful Article

Over 98% of websites use JavaScript to create dynamic and interactive content. It is a popular choice for websites due to its compatibility with major browsers. 

Check out this TechJury article for different ways to scrape JavaScript-powered sites.

Conclusion

Exporting HTML tables to Excel allows you to handle data easily due to the spreadsheet program’s straightforward interface and practical features.

HTML tables in Excel connect visually appealing websites to robust spreadsheet tools, giving users the opportunity to work with big data sets. Each exporting technique mentioned in this article suits different needs, so use the best method for your needs and resources.

FAQs.


Can you convert HTML to CSV?

You can convert HTML to CSV by separating the values with commas. You can automate the process using various tools if you have too much data to handle.

What is an HTML export?

An HTML export means converting data from a system into a format you can show on a web page. It involves using HTML elements to style and structure the content for web display.

Does HTML transfer data?

No, HTML does not transfer data. It is a markup language used for organizing content on the web page. Data transfers usually need more tools like forms, requests, or APIs.

SHARE:

Facebook LinkedIn Twitter
Leave your comment

Your email address will not be published.