Updated 2026-11-09
Excel Says the File Format and Extension Don't Match. What Now?
The warning is not about the name of the file. It means Excel opened the first few hundred bytes, compared them with what a .csv should look like, and found something else.
Quick answer
In most cases the file is not a CSV. It is an HTML page, an XML spreadsheet, or a workbook saved with the wrong extension, usually because an export link returned a login page or an error page that the browser saved as.csv. Open the file in Notepad and look at the first line. That single step tells you which of the four causes you have, and only one of them needs anything other than a re-export.
Read the first line before anything else
Notepad, TextEdit, or head -c 200 file.csv in a terminal. The first characters point to the cause:
| First line starts with | What the file really is | Fix |
|---|---|---|
<!DOCTYPE html or <html | A web page: expired session, login redirect, or an error message | Sign in again and re-run the export. No converter can recover rows that were never sent. |
<?xml with <Workbook | Excel 2003 XML Spreadsheet | Open it, then Save As CSV. Excel reads this format natively. |
PK then unreadable bytes | A zipped Office file: .xlsx or .ods renamed to .csv | Rename it back to .xlsx and open it as a workbook. |
| Readable text with commas, semicolons or tabs | A real delimited file, but the delimiter or encoding tripped the check | Import through Data, then From Text/CSV and choose the delimiter yourself. |
The HTML case is the one that catches people, because the file has the right name, a plausible size, and no obvious damage. It also survives renaming, which is why "I already tried saving it again" does not help.
Import instead of double-click
Double-clicking asks Excel to guess. Going through Data then From Text/CSV asks you. The wizard shows the first rows as it reads them, lets you set the file origin, the delimiter and the data type per column, and it does not care what the file is called.
- Set File Origin to the encoding the export used. 65001 is UTF-8; 1252 is Western ANSI.
- Pick the delimiter from the preview, not from the extension. Semicolon and tab exports are common from European and database systems.
- Set ID-like columns to Text before loading, so account numbers keep their leading zeros.
- Use Transform Data rather than Load if the header row is not row 1.
For a one-off look at the data, the CSV cleaner opens the file in the browser and shows the parsed table with the delimiter it detected, which is often enough to confirm the file is fine and Excel was the problem.
The four causes, in order of frequency
1. Export returned a web page. Session timeouts, single sign-on redirects and rate limits all produce HTML with a 200 status, so the browser happily saves it. Check the file size: a few kilobytes is suspicious for a data export.
2. Wrong extension on a workbook. Someone exported .xlsx and renamed it. The PK signature in the first two bytes is the giveaway.
3. Excel 2003 XML.Still produced by a number of ERP and accounting systems that offer "Excel" export. It opens fine once you accept the warning.
4. A genuine CSV with an unusual dialect. A file whose fields start with ID in the first two characters can be mistaken for SYLK, an old spreadsheet interchange format. Renaming the column or adding a header comment is enough to get past it.
When the file came from the internet
Windows marks files downloaded from the web, and Office opens those in Protected View. If the warning appears together with a yellow bar, the two are separate issues. Right-click the file, open Properties, and tick Unblock if you trust the source. That removes the mark, not the format check.
There is one case where you should stop rather than click through: a file you did not ask for, arriving by email with a .csv name. Because Excel will render HTML content, an attachment of that shape can carry a script. Delete it and ask the sender for a real export.
If Excel opens it but the rows look wrong
A different problem with a similar symptom: everything lands in column A. That is a delimiter mismatch, covered in CSV opens in one column. If the characters are garbled instead, it is encoding, covered in garbled CSV in Excel. And if Excel opens the file but stops partway down, the row limit is the cause: 1,048,576 rows per sheet, which the Excel row limit page explains with the workarounds.
FAQ
What does "the file format and extension of X don't match" mean?
Excel has looked inside the file and decided the content is not what a .csv extension promises. The message is about the bytes, not the filename. Clicking Yes usually opens the file, and it is safe to do when you know where the file came from.
Why does my .csv file contain HTML?
Most often an export link returned a web page instead of the file: an expired session, a login redirect, or an error page saved under the .csv name. Open the file in Notepad. If the first line starts with <!DOCTYPE html or <html, no converter will help and the export needs to be run again from a signed-in session.
Is it safe to click Yes and open the file anyway?
If you produced or requested the file yourself, yes. Excel is warning that the content will be interpreted differently from the extension. If the file arrived unsolicited by email, do not open it: an HTML file that arrives named .csv can carry a script, and there is no reason to accept that risk for an unexpected attachment.
How do I open a CSV in Excel without the warning?
Use Data then From Text/CSV. The import wizard reads the file as data and lets you choose the delimiter and the encoding, so the extension check never runs. This is also the only reliable way to open a CSV that uses semicolons or tabs instead of commas.
Find the broken row before the import does
Seven checks for a CSV that will fail on import covers truncation, field counts and encoding in one pass. If the file is clean and the importer still fails, the problem is the receiving system, not the bytes.
Related reading
Data Cleaning — other guides that pair well with this one.
- Remove Blank Rows from CSV
- Fix Garbled CSV in Excel
- How to Add Row Numbers to a CSV File (Excel, Sheets, Python)
- Empty CSV File: Fixing pandas 'No columns to parse from file'
Browse all guides in the NoCodeCSV blog.