Excel "file format or file extension is not valid": how to fix it
Excel looked inside the file and found something that does not match its extension. Usually the file is a CSV, HTML or old .xls file saved with a .xlsx name, or it is damaged or only partly downloaded. The quickest fix is in Excel for Windows: go to File > Open > Browse, select the file, click the arrow next to Open and choose Open and Repair.
What this message means
Every Excel file type has a set internal structure. A modern .xlsx or .xlsm file is a zipped package of XML files. An .xls file uses an older binary format. A .csv file is plain text. When you open a file, Excel checks that its contents match the extension in the name. If they don't match, or the contents can't be read at all, Excel refuses to open it and shows this message. The file is not necessarily lost. The name may just be wrong, or the damage may be partial. Excel also shows this message when the file's contents have been encrypted by ransomware.
Common causes
| Cause | How to tell |
|---|---|
| The file was renamed or exported with the wrong extension (for example, a CSV or HTML report saved as .xlsx, or an .xls saved as .xlsx). | The file usually comes from a website, a bank, an accounting system or a colleague's export. Right-click it and open it in Notepad (Windows) or TextEdit (Mac). Readable rows separated by commas or tabs mean it is CSV or text. Tags like <html> or <table> mean it is a web page. A genuine .xlsx file starts with the letters PK followed by unreadable characters. |
| The file is incomplete: an interrupted download, a failed email attachment, or a copy from a USB drive that was removed too early. | In File Explorer or Finder, the file shows as 0 KB or much smaller than expected. Downloading the same file again or getting a fresh copy from the sender opens without an error. |
| The workbook is corrupted, for example after a crash or power loss while saving, a failing drive, or a sync conflict in OneDrive, SharePoint or Dropbox. | The file has a normal size and opened fine before, but now fails every time. Notepad shows it starting with PK, so it is a real .xlsx package with damage inside. Open and Repair often recovers some or all of it. |
| The file was created in another program and isn't a real Excel file. Examples are an Apple Numbers file, or an old Lotus 1-2-3, Works or Quattro Pro file, given an Excel extension. | Whoever sent the file uses a Mac with Numbers or an old system. Excel 2007 and later cannot open Lotus .wk1 to .wk4, Works .wks or Quattro Pro files at all. |
| Ransomware or other malware has encrypted the file. | Several files of different types (Word, PowerPoint, PDF, photos) fail to open at once. You may see new ransom-note files or strange extensions added to file names. Notepad shows random characters with no PK at the start. |
How to fix it
1. Use Open and Repair
Excel for Microsoft 365, 2024, 2021, 2019 and 2016 on Windows. Excel for Mac has no Open and Repair option.
- Open Excel with a blank workbook. Don't double-click the broken file.
- Go to File > Open > Browse.
- Find and click the file once to select it.
- Click the small arrow next to the Open button and choose Open and Repair.
- Click Repair to recover as much as possible. If that fails, repeat the steps and click Extract Data to recover values and formulas without formatting.
- Save the recovered workbook straight away with File > Save As, under a new name.
2. Check what the file really is, then give it the correct extension
To show extensions: Windows 11 File Explorer > View > Show > File name extensions. Windows 10 File Explorer > View tab > tick File name extensions. Mac Finder > Settings (Preferences on older macOS) > Advanced > Show all filename extensions.
- Make a copy of the file so you can always go back to the original.
- Turn on file name extensions (see the note above) so you can see the full name, for example report.xlsx.
- Right-click the copy and open it with Notepad (Windows) or TextEdit (Mac).
- If it starts with PK, it's a real .xlsx or .xlsm file. Skip to Open and Repair or a backup.
- If you see comma- or tab-separated text, rename the copy to .csv. If you see <html> or <table>, rename it to .html. If you see unreadable binary text with no PK at the start, try renaming it to .xls.
- Open the renamed file in Excel. If it opens correctly, use File > Save As > Excel Workbook (*.xlsx) to turn it into a proper Excel file.
3. Get a fresh copy of the file
- Delete the file that won't open, or move it somewhere else.
- Download it again from the website, email or system it came from. On a slow connection, wait for the download to finish completely.
- Check that the new copy has a sensible size (not 0 KB).
- If a colleague or a system created it, ask them to re-export it as Excel Workbook (.xlsx) rather than CSV or HTML.
4. Restore an earlier version from OneDrive, SharePoint or Windows
OneDrive version history is kept for 30 days. Work or school admins can turn it off. Windows Previous Versions only works if File History or restore points were already turned on.
- For OneDrive: right-click the file in File Explorer (with the OneDrive app running), or at OneDrive.com, and choose Version history.
- Click the three dots (...) next to a version dated before the problem started, then choose Restore.
- For SharePoint or Teams files: open the file's folder in the browser, click the three dots next to the file, then choose Version history.
- For local files on Windows: right-click the file, choose Properties > Previous Versions, pick an older copy and click Restore.
- On a Mac with Time Machine: open the file's folder in Finder, open Time Machine from the menu bar, and restore an older copy.
5. Rescue the data with an external reference
Excel for Windows. Use this when Open and Repair fails but the file is still a real Excel package (it starts with PK).
- Put the damaged file in an easy folder, for example C:\Temp, and give it a short name like Broken.xlsx.
- Create a new blank workbook and save it in the same folder.
- In cell A1, type =Broken.xlsx!A1 and press Enter. If Excel shows an Update Values dialog, pick the damaged file and choose the sheet you want.
- Drag the formula across and down far enough to cover the original data.
- Select the cells, copy them, then use Paste Special > Values to break the link. You'll get the values back, but not formulas or formatting.
6. Scan for malware if many files broke at once
- Disconnect the computer from the network and from any external drives.
- Run a full scan in Windows Security (Virus & threat protection > Scan options > Full scan), or run Microsoft Safety Scanner.
- Removing the malware won't decrypt files that are already damaged. Restore them from a backup or cloud version history made before the infection.
- At work, contact your IT or security team before doing anything else.
Next time, skip the search
Crade is an AI assistant for Mac and Windows that sees your screen. When a message like this pops up, ask “what does this mean?” and it explains the exact error in front of you, step by step.
Download CradeStill not fixed?
If the file starts with PK and still won't open after Open and Repair, try opening it in another program such as LibreOffice Calc or Google Sheets (upload it to Google Drive and open it there). They sometimes read files that Excel rejects, and you can save the result back as .xlsx. If the file lives on a work SharePoint, OneDrive or Teams site, your IT admin may be able to restore it from versions or the recycle bin beyond what you can see yourself. If the file came from a business system (bank, payroll, ERP), contact that vendor's support and ask for a real .xlsx export. The mismatch is usually on their side. Avoid paid "Excel repair" tools until you have tried a backup or version history.
Questions people ask
Will changing the extension from .xlsx to .xls fix it?
Only when the file really is an old .xls or an HTML/XML export mislabeled as .xlsx. Look inside with Notepad first. If it starts with PK, it's already a real .xlsx and renaming won't help.
Why does a file I downloaded from my bank or accounting software show this error?
Many web systems export CSV or HTML tables but name the file .xlsx. Rename it to .csv or .html and it will usually open, then save it as a proper Excel Workbook.
Can I recover a file that shows 0 KB?
No. A 0 KB file contains no data. Download it again, or restore it from OneDrive version history, Previous Versions or Time Machine.
Why does the file open on my colleague's computer but not mine?
Your copy may be incomplete or damaged in transit, so compare the file sizes. If the sizes match, your Excel may be older than theirs or blocked by company policy. Update Office (File > Account > Update Options > Update Now) and try again.
Is Open and Repair available on a Mac?
No, Excel for Mac has no Open and Repair option. On a Mac, check the real file type with TextEdit, try opening it in Numbers or Google Sheets, or run Open and Repair in Excel on a Windows PC.
Sources
- Repair a corrupted workbook (Microsoft Support)
- File formats that are supported in Excel (Microsoft Support)
- Restore a previous version of a file stored in OneDrive (Microsoft Support)
- "Excel cannot open the file because the file format or file extension is not valid" (Microsoft Excel Support Team Blog archive)
- Excel "file is locked for editing by another user": how to fix it
- Excel #CALC! error: what it means and how to fix it
- Excel can't insert new cells (push non-empty cells off worksheet): fix
- Excel "There are one or more circular references": how to fix
- Excel #DIV/0! error: what it means and how to fix it
- Excel #GETTING_DATA: what it means and how to fix it