To convert an HTM file to Excel, the fastest method is to open Microsoft Excel, go to the File menu, select Open, and choose the .htm or .html file from your computer. Excel will automatically parse the HTML table tags and render the data into a standard spreadsheet grid. This process allows you to transform web-based data tables into a manipulatable format for analysis, calculations, and reporting.
Converting HTM (HyperText Markup Language) files to Excel is a common requirement for users who export reports from legacy banking systems, government databases, or old web applications. While HTM files are designed to be viewed in a web browser, they often contain structured data in the form of tables. By importing these into Excel, you move the data from a static visual presentation to a functional database where you can apply filters, create pivot tables, and perform complex mathematical operations. Depending on how the original HTML was coded, the data may arrive perfectly clean or may require some light formatting to be usable.
What You'll Need
- A computer with Microsoft Excel installed (Windows or macOS).
- The .htm or .html file saved locally on your hard drive.
- Administrative permissions to open files from the internet (if the file was downloaded).
Step-by-Step
- Locate your HTM file: Ensure the file is saved in a known folder, such as your Downloads or Documents folder. If the file is currently open in a web browser, you must first save it to your computer by pressing Ctrl+S (Windows) or Cmd+S (Mac) and selecting "Webpage, HTML only".
- Launch Microsoft Excel: Open a blank workbook or start the application from your desktop.
- Open the File Menu: Click on the File tab in the top-left corner of the ribbon. Note that menu labels may differ slightly depending on your version of Excel or your operating system.
- Navigate to Open: Select Open from the left-hand sidebar, then click Browse. This will open the system's file explorer window.
- Change the File Type Filter: By default, Excel looks for .xlsx or .xls files. In the bottom-right corner of the Open dialog box, click the dropdown menu that says "All Excel Files" and change it to All Files (*.*) or Web Pages. This allows the .htm file to appear in the list.
- Select and Open: Click once on your .htm file to highlight it, then click the Open button.
- Handle Security Warnings: If Excel displays a warning stating that the file format and extension don't match or that the file originates from an untrusted source, click Yes to proceed. This happens because HTM is a web format, not a native spreadsheet format.
- Review the Data Layout: Once the file opens, Excel will attempt to place every HTML <td> (table data) element into a cell. Check if the columns align correctly. If the HTML used nested tables, you may see merged cells or empty columns.
- Convert to XLSX Format: The file is currently open as a web page, meaning you cannot save spreadsheet-specific formulas or formatting back into the .htm file. Go to File > Save As, click the file type dropdown, and select Excel Workbook (.xlsx). Give the file a new name and click Save.
Common Mistakes
One of the most frequent errors is attempting to "Open With" Excel directly from the Windows File Explorer. While this sometimes works, it can occasionally trigger a "File format not valid" error or open the file in a protected view that prevents editing. Using the internal File > Open menu within Excel is the most reliable method because it triggers the correct import engine.
Another common mistake is forgetting to change the file extension during the final save. If you simply hit "Save," Excel may try to keep the file as an .htm file. This means any formulas you add, conditional formatting you apply, or new sheets you create will be lost the moment you close the program, as HTML files cannot store Excel-specific metadata.
Users also often overlook the "Save As" type when downloading the file from a browser. If you save a page as "Webpage, Complete," the browser creates a folder containing all images and CSS files. Excel cannot open this folder; it only needs the single .htm file. Ensure you select "HTML Only" to keep the process clean.
Tips
To clean up the data quickly after importing, use the Find and Replace tool (Ctrl+H). Web-exported data often contains non-breaking spaces or special characters (like ) that can interfere with formulas. Replacing these with a standard space ensures your VLOOKUPs and SUM functions work correctly.
If the data appears shifted or misaligned, try using the Text to Columns feature under the Data tab. This is particularly useful if the HTML was poorly structured and dumped multiple data points into a single cell separated by commas or tabs.
For those dealing with very large HTM files that cause Excel to freeze, try opening the file in a text editor (like Notepad) first to see if there is a massive amount of unnecessary header code. If the file is too large for a standard open, you can try the Data > Get Data > From File > From Text/CSV route, although this is more suited for CSVs than HTMs.
Troubleshooting
If the file opens but looks like a mess of code (showing tags like <div> or <table>), it means the file is not a true HTML table but a text file with an .htm extension. In this case, you cannot "open" it; you must "import" it. Go to the Data tab, select From Text/CSV, and attempt to import the file. If the code is still visible, the data is not structured as a table and may require a dedicated HTML scraper tool.
If you receive a "File is corrupt and cannot be opened" message, check the file extension. Ensure it is .htm or .html and not .htm.txt. If the extension is wrong, right-click the file, select Rename, and remove the .txt suffix. If the error persists, try opening the file in a web browser first. If the browser cannot render it, the file itself is likely corrupted during the download process, and you should try downloading it again.
When data appears as a single long column instead of a table, it usually indicates that the original web page used "div" tags for layout instead of "table" tags. Excel's basic import only recognizes <table>, <tr>, and <td> tags. If the data is in divs, the best workaround is to copy the data directly from the browser window, paste it into Excel, and then use the Paste Special menu to select "Match Destination Formatting."
Frequently Asked Questions
Can I convert HTM to Excel without installing Microsoft Office?
Yes, you can use Google Sheets. Upload the .htm file to Google Drive, right-click it, and select Open with > Google Sheets. From there, you can download it as an .xlsx file via File > Download.
Why are there empty rows and columns after the import?
This happens when the original HTML used empty cells or padding for visual spacing. You can remove these quickly by selecting the entire sheet, pressing Ctrl+G, clicking Special, selecting Blanks, and then right-clicking a highlighted cell to select Delete > Entire row/column.
Will the hyperlinks in the HTM file still work in Excel?
Generally, yes. Excel recognizes the <a href> tags in HTML and converts them into clickable hyperlinks within the cell. However, if the links were relative paths (linking to files on a specific server), they may break once the file is moved to your local drive.
Is there a limit to how much data Excel can import from an HTM file?
Excel is limited by its maximum row count (1,048,576 rows). If the HTM file contains a table larger than this, the data will be truncated. For datasets larger than one million rows, you should use a database tool or Power BI.
Does this method work for .html files as well as .htm?
Yes, .htm and .html are functionally identical. Excel treats both extensions the same way during the import process.