Excel says the file format or extension is not valid

This message appears when Excel reads the start of the file and finds something different from what the extension promises. The classic case is a file that was renamed: a CSV, an HTML table, an older .xls, or a completely different document wearing an .xlsx extension. Corruption can produce the same verdict, but a mismatch between name and contents is the cause to rule out first, because it is also the quickest to fix.

The fix, in order

  1. Work on a copy, always. Copy the file first and experiment on the copy. Several steps below involve renaming, and the original is the fallback if a recovery route goes wrong.
  2. Check the file size and origin. A file of 0 KB or a few hundred bytes is not a workbook; email gateways and failed downloads leave stubs like that. Re-download or ask for the file again rather than repairing a stub.
  3. Identify the real format. Open the copy in a text editor and look at the first characters. PK means a real xlsx zip package. <html or <table means a web page export. %PDF means a PDF. Match the extension to what the file actually is, then open it in the right program or in Excel with the correct type.
  4. Correct a wrong extension. If the contents are a genuine older Excel file, renaming .xlsx to .xls on the copy (or the reverse, matching the real format found in step 3) lets Excel open it without complaint. Extensions must be visible in Explorer's View settings to do this reliably.
  5. Use Open and Repair. In Excel: File, Open, browse to the copy, click the arrow next to Open, and choose Open and Repair. If repair fails, repeat and choose Extract Data to recover values and formulas without formatting.
  6. Look for an untouched copy. Check AutoRecover (File, Info, Manage Workbook), the email or download the file came from, and Previous Versions on the file's Properties tab. An uncorrupted original beats any repair.

If it still happens

A file that is a genuine xlsx package (starts with PK) and still fails Open and Repair usually has damage inside the package, most often in the shared strings or a single worksheet part. Opening it with the file type set to Excel Workbook in LibreOffice, a free office suite from its official site, sometimes reads past damage that Excel refuses, letting the data be saved out cleanly.

Common questions

Why did this file open fine last week? If nothing renamed it, suspect where it has been stored since: a failing USB stick, a sync folder caught mid-upload, or an email system that stripped and reattached it can all alter bytes. The error reports the current state of the file, not its history.

Is this error a sign of a virus? Not by itself. Mismatched extensions happen constantly through exports and renames. As with any unexpected file, scan it with the installed antivirus before opening, especially if it arrived unsolicited.

Related errors

Excel cannot open the file · Word file is corrupted · PowerPoint found a problem with content