How to Corrupt an Excel File (.xlsx) Step by Step

Posted on by CorruptAnyFile Team

How to Corrupt an Excel File (.xlsx) Step by Step

If you build tools that import spreadsheets, you need to know how they behave with damaged workbooks. Here is how to create one safely.

How Excel files are stored

An .xlsx file is a ZIP archive containing XML files, like Word's .docx. It includes xl/workbook.xml, sheet files in xl/worksheets/ and shared strings. The older .xls format is a binary format. Damage to either makes Excel complain.

Method 1: Online Excel file corrupter

  1. Open CorruptAnyFile.
  2. Upload your XLSX or XLS file.
  3. Click Corrupt My File.
  4. Download the result.

The tool supports XLS, XLSX and CSV among its 24 formats.

Method 2: Zero the ZIP header

In a hex editor, change the first bytes 50 4B 03 04 to zeros on a copy. Excel will report that the file format or extension is not valid.

Method 3: Edit the XML

  1. Rename a copy to .zip and extract it.
  2. Open xl/worksheets/sheet1.xml.
  3. Remove a closing </sheetData> tag.
  4. Re-zip and rename to .xlsx.

Excel will normally say it found a problem with content and offer to repair the file.

Method 4: Truncate

head -c 2500 data.xlsx > broken.xlsx

CSV files

CSV is plain text, so corruption looks different. Test ragged rows, missing quotes, stray binary characters and wrong encodings. These problems cause far more real-world import bugs than a destroyed ZIP.

Excel error messages you will see

  • "Excel cannot open the file because the file format or file extension is not valid."
  • "We found a problem with some content. Do you want us to try to recover as much as we can?"

Try File > Open > Open and Repair to see how recovery behaves. More recovery steps are in our guide to fixing corrupted files.

Related guides

How to corrupt a file, Word documents and PDFs.

FAQ

Can I corrupt an Excel file online? Yes, with CorruptAnyFile.

Why does Excel say the file format is not valid? The header or ZIP structure is damaged, or the extension does not match.

Can corrupted Excel files be recovered? Often partially, using Open and Repair.