The basics
What is an XLS file?
XLS is the file format of Microsoft Excel up to Excel 2003. A workbook in it holds sheets of cells with values, formulas, formatting, charts, comments, names and, optionally, macros. Excel 2007 replaced it with XLSX as the default, but every spreadsheet program still reads XLS, and some older business systems and exports still produce it.
When people say XLS they nearly always mean the Excel 97-2003 format, BIFF8. Earlier Excel versions used older BIFF versions with the same .xls extension.
Three things worth knowing up front:
- It's limited to 65,536 rows and 256 columns per sheet. Data beyond that is lost when a workbook is saved as XLS.
- It can contain macros under the same extension. There's no separate macro-free variant, as
.xlsxis for.xlsm. - Not every .xls file is one. Many web apps export an HTML table or a CSV file and call it
.xls. Excel then warns that the file format and extension don't match.
Anatomy
What's inside an XLS file
An XLS file is an OLE2 compound file, a small file system in one file, with the workbook in a stream called Workbook. That stream is a list of records, each with a 2-byte type, a 2-byte length and its data. This is our sample-minimal.xls: four cells on one sheet.
$ xxd -l 80 sample-minimal.xls (first 80 of the 512 header bytes)
00000000: d0cf 11e0 a1b1 1ae1 0000 0000 0000 0000 ................
00000010: 0000 0000 0000 0000 3b00 0300 feff 0900 ........;.......
00000020: 0600 0000 0000 0000 0000 0000 0100 0000 ................
00000030: 0900 0000 0000 0000 0010 0000 0200 0000 ................
00000040: 0100 0000 feff ffff 0000 0000 0000 0000 ................
Streams: Workbook 1,815 bytes, \x05SummaryInformation 408,
\x05DocumentSummaryInformation 168, \x01CompObj 73, \x01Ole 20
Workbook stream, record by record (offset, type, name, length, data):
0000 0809 BOF 16 00 06 05 00 bb 0d cc 07 …
00e2 0022 DATEMODE 2 00 00
00fa 0031 FONT 30 dc 00 00 00 08 00 90 01 … C.a.l.i.b.r.i
01a8 00e0 XF 20 (22 XF records: cell and style formats)
03ee 0085 BOUNDSHEET 14 e8 04 00 00 00 00 06 00 "Sheet1"
0472 00fc SST 71 02 00 00 00 02 00 00 00 0d 00 00 "Hello, world." …
04e4 000a EOF 0
04e8 0809 BOF 16 00 06 10 00 bb 0d cc 07 …
05cc 0200 DIMENSIONS 14 00 00 00 00 04 00 00 00 00 00 01 00 00 00
062e 00fd LABELSST 10 00 00 00 00 15 00 00 00 00 00
063c 00fd LABELSST 10 01 00 00 00 0f 00 01 00 00 00
064a 027e RK 10 02 00 00 00 0f 00 aa 00 00 00
0658 0006 FORMULA 31 03 00 00 00 0f 00 00 00 00 00 00 00 55 40 …
0713 000a EOF 0- 1
d0cf 11e0 a1b1 1ae1The OLE2 signature
The same 8 bytes start every compound file, including DOC and PPT files, so they only say "compound file". The rest of the 512-byte header (version 3, little-endian, 512-byte sectors, 4,096-byte mini stream cutoff) is laid out exactly as in a DOC file.
- 2
Workbook 1,815 bytesThe Workbook stream
All the cells, formats, sheets and charts. Excel 5.0 and 95 called this stream
Book; a file withBookand noWorkbookis the older BIFF5 format. Properties sit in the two summary streams, as in Word and PowerPoint files. - 3
0809 BOF · 00 06 05 00Beginning of file
0x0600means BIFF8, and0x0005means the workbook globals substream follows: settings, fonts, formats and the list of sheets. Each sheet then has its own substream from BOF to EOF. - 4
0022 DATEMODE · 00 00The date system
0 for the 1900 date system, 1 for 1904. Dates are stored as serial numbers, the same as in XLSX, so this one flag shifts every date by 1,462 days.
- 5
0031 FONT · 00e0 XFFonts and cell formats
Every distinct combination of font, number format, fill and border is an XF record. A cell refers to one by its index. Excel 97-2003 allows about 4,000 of them per workbook.
- 6
0085 BOUNDSHEET · e8 04 00 00A sheet entry
The sheet's name, visibility and type, and where its substream starts: offset
0x04E8in the stream. A hidden sheet has visibility 1, a very hidden one 2. - 7
00fc SST · 0d 00 00 Hello…The shared string table
Every distinct text, stored once. Each string has a length, a flag byte and the characters: flag
00means 1 byte per character,01means UTF-16. Longer tables continue in CONTINUE records, since a BIFF8 record holds at most 8,224 bytes of data. - 8
0200 DIMENSIONSThe used range
First row 0, last row + 1 = 4, first column 0, last column + 1 = 1: the sheet uses A1:A4. Readers use it to size their tables before reading cells.
- 9
00fd LABELSST · 00 00 00 00 15 00 00 00 00 00A text cell
Row 0, column 0 (A1), format 0x15 (bold), string 0 from the SST: "Hello, world."
- 10
027e RK · aa 00 00 00A compact number
RK records squeeze common numbers into 4 bytes.
0xAAhas its "integer" bit set; shifted right by 2 it gives 42, the value of A3. - 11
0006 FORMULA · 00 00 00 00 00 00 55 40A formula and its result
A4 holds
=A3*2. The record stores the last result first, here the 8-byte number 84.0, then the formula as compiled tokens, not as text. A reader has to rebuildA3*2from those tokens.
Under the hood
How an XLS file is put together
Like DOC and PPT, an XLS file is a Compound File Binary (OLE2) file: a FAT-style file system inside one file. The workbook lives in the Workbook stream, as a sequence of BIFF records. Excel reads them in order, from the workbook's settings to the last cell of the last sheet.
- Globals first, then one block per sheet. The workbook globals hold fonts, number formats, cell formats (XF), the colour palette, the shared strings and a BOUNDSHEET record per sheet. Each sheet follows as its own BOF … EOF block.
- Cells are records. LABELSST for text, NUMBER for an 8-byte number, RK and MULRK for compact numbers, BOOLERR for TRUE, FALSE and errors, BLANK for a formatted empty cell, FORMULA for a formula.
- Formulas are compiled. XLSX stores the formula text,
SUM(A1:A9). XLS stores parsed tokens in reverse Polish order, plus the cached result. That's why simple XLS readers often show only the results. - Text is stored once. The shared string table holds each distinct string, as 8-bit characters when every character fits, otherwise as UTF-16.
- Records are small. A BIFF8 record carries at most 8,224 bytes of data; longer content continues in CONTINUE records. Charts, drawings and comments are records too, some wrapping Office drawing data.
- Dates are numbers, exactly as in XLSX: a serial day count with a number format. A DATEMODE record chooses between the 1900 and 1904 date systems.
Look inside one yourself
In Python, olefile lists the streams, and xlrd reads the cells, formats and dates of any BIFF8 file. Microsoft documents the format in the [MS-XLS] specification, and Apache OpenOffice's older "Excel File Format" write-up is still a readable introduction.
Versions
BIFF versions: from Excel 2 to Excel 2003
| Excel version | Format | How to tell |
|---|---|---|
| Excel 2.x, 3.0, 4.0 (1987 to 1992) | BIFF2, BIFF3, BIFF4 | A plain stream of records, not a compound file. Usually one sheet per file. |
| Excel 5.0 (1993) and Excel 95 | BIFF5 | A compound file with a Book stream; several sheets per workbook. Text in an 8-bit code page. |
| Excel 97 to 2003 | BIFF8 | A Workbook stream, BOF version 0x0600, Unicode text. This page's format. |
| Excel 97 to 2003, dual format | BIFF5 and BIFF8 | The "Excel 97 & 5.0/95 Workbook" option wrote both streams in one file, for colleagues on older versions. |
| Excel 2007 and later | XLSX by default | A ZIP of XML. Excel still opens and saves .xls as Excel 97-2003 Workbook. |
When current Excel opens an XLS file, it shows Compatibility Mode in the title bar, keeps saving in the old format and turns off features that it can't store. To leave it, save the workbook as XLSX.
Limits
XLS limits, and what the Compatibility Checker warns about
| XLS (Excel 97-2003) | XLSX (Excel 2007 and later) | |
|---|---|---|
| Rows × columns per sheet | 65,536 × 256 (IV) | 1,048,576 × 16,384 (XFD) |
| Unique cell formats | 4,000 | 64,000 |
| Nesting levels in a formula | 7 | 64 |
| Arguments in a function | 30 | 255 |
| Characters in a formula | 1,024 | 8,192 |
| Conditional formatting conditions shown | 3 | 64 |
| Sort levels | 3 | 64 |
| Colours | The 56-colour palette | Any colour |
When you save a newer workbook as .xls, Excel runs the Compatibility Checker and lists what will be lost or changed, with Find buttons that take you to the cells. You can also run it yourself: File, Info, Check for Issues, Check Compatibility. Rows and columns beyond the grid are lost, formulas that refer to them return #REF!, and colours are replaced by the nearest palette colour.
Exporting more than 65,536 rows to XLS doesn't fail loudly in every program: some silently stop at row 65,536. If a report seems to end early, check the row count. Use XLSX or CSV for bigger tables.
Comparison
XLS vs XLSX, XLSB, ODS and CSV
| XLS | XLSX | XLSB | ODS | CSV | |
|---|---|---|---|---|---|
| Structure | BIFF8 records in an OLE2 file | ZIP of XML | ZIP of binary parts | ZIP of XML | Plain text |
| Rows per sheet | 65,536 | 1,048,576 | 1,048,576 | Set by the app (LibreOffice: 1,048,576) | No limit in the format |
| Macros | Yes, same extension | No (.xlsm instead) | Yes | Yes | No |
| Open standard | Documented, not a standard | Yes (ISO/IEC 29500) | Documented, not a standard | Yes (ISO/IEC 26300) | RFC 4180 (informational) |
| Formulas stored as | Compiled tokens | Text | Compiled tokens | Text | Values only |
Use XLSX for anything new. Keep XLS only when the receiving system can't read anything else, and use CSV when the data goes into another program.
Troubleshooting
Common XLS problems and how to fix them
- "The file format and extension don't match." The file is really HTML, XML or CSV with an
.xlsname, as many web exports are. Open it in a text editor: a real XLS file is binary and starts withÐÏ(the bytesD0 CF). If you trust the source, open it anyway and save it as XLSX. - Rows are missing after an export or save. XLS stops at 65,536 rows and 256 columns. Save as XLSX instead.
- Dates are 4 years and 1 day off. The file uses the 1904 date system and the reader ignored the DATEMODE record, or the other way round.
- Colours look different. XLS stores colours as indexes into a 56-colour palette, and newer colours are mapped to the nearest one. A program that ignores the workbook's own palette shows default colours.
- Formulas show old values in a preview. Previews and libraries such as
xlrdshow the stored results without recalculating. Open the file in a spreadsheet app to recalculate. - Leading zeros or long numbers change. As in any Excel file, numbers keep 15 significant digits. Store IDs and phone numbers as text.
How to
How to open, edit and convert an XLS file
- Excel on Windows and Mac opens XLS in Compatibility Mode. Excel for the web and the mobile apps can open them too.
- Without Excel: LibreOffice Calc (free, Windows, Mac, Linux) opens and saves XLS. Google Sheets opens XLS files uploaded to Google Drive. Numbers on Mac, iPhone and iPad imports them.
- In a browser: browsers can't display an XLS file, so a link to one downloads it.
- Convert to XLSX: in Excel, File, Save As, Excel Workbook (.xlsx). On a server:
soffice --headless --convert-to xlsx old.xls. - Convert to CSV: File, Save As, CSV. Only the active sheet is saved, and formulas become values.
- With code: in Python,
xlrdreads XLS (since version 2.0 it reads only XLS), and pandas uses it for.xlsfiles. SheetJS reads XLS in JavaScript and Apache POI (HSSF) in Java.
Security
Is an XLS file safe to open?
XLS files deserve more caution than XLSX, because the extension doesn't tell you whether there are macros inside. Spreadsheets with macros have been a favourite malware attachment for decades.
- VBA macros run once you click Enable Content; a
Workbook_OpenorAuto_Openmacro then runs as soon as the workbook opens. Since 2022, Office on Windows blocks macros in files that came from the internet. - Excel 4.0 (XLM) macros are older still: formulas on special macro sheets, dating from 1992, a year before VBA. Malware used them heavily because older security tools didn't look at them, often on hidden or very hidden sheets. Microsoft 365 now disables them by default.
- External links and data connections can fetch content from other files and servers. Excel asks before updating them; only allow it for files you trust.
- Hidden content travels with the file: hidden rows, columns and sheets, comments, and author names in the document properties.
- Weak encryption. A password-protected XLS uses XOR obfuscation or RC4, often with a 40-bit key, which can be broken regardless of the password. The document properties may stay readable without it.
If you didn't expect a spreadsheet, don't enable content. If your server reads uploaded XLS files, use a maintained library, set limits on size and row counts, and treat cell text as untrusted when you write it into other files or pages.
Free downloads
Sample XLS files to download
Free sample Excel 97-2003 workbooks for testing uploads, previews and spreadsheet libraries. LibreOffice wrote each one (from workbooks made with openpyxl) after recalculating, so every formula carries its result. All were read back with xlrd. None contains macros.
Browsers can't show this kind of file in a page. Download it to open it in the app it belongs to.
What's inside sample-workbook.xls
Browsers can't preview XLS files, so download it and open it in Excel, LibreOffice, Google Sheets or Numbers. It holds the same orders as our sample XLSX workbook, so you can compare the two formats.
Orders sheet with an AutoFilter
Twelve fictional orders with filter buttons and a frozen header row. XLS has no Excel tables, so this is a plain range with an AutoFilter, which is what a table becomes when you save XLSX as XLS.
Order IDs as text
000184and the rest keep their leading zeros because they're text in the shared string table.Dates and currency
Dates are serial numbers formatted
yyyy-mm-dd; prices use a euro number format. The first date is stored as 46296.Formulas with cached results
=E2*F2on every row andSUMin the totals row, stored as compiled tokens with their results.Conditional formatting and palette colours
Quantities of 5 or more are highlighted by a rule. The blue header fill is an index into the workbook's 56-colour palette, which LibreOffice adjusted to hold that exact blue.
Summary sheet: SUMIF and a chart
SUMIFformulas that read the Orders sheet, and a bar chart stored as BIFF8 chart records.About sheet and properties
A description of the file, and document properties (title, author, comments) in the summary streams.
All sample XLS files
Sample workbook
sample-workbook.xls · 13.5 KB (13,824 bytes)
Three sheets: orders with dates, currency, formulas, an AutoFilter and conditional formatting; a summary with
SUMIFformulas and a bar chart; and an About sheet. Fictional data.- Testing spreadsheet previews and libraries
- Comparing XLS and XLSX output
Minimal XLS
sample-minimal.xls · 6 KB (6,144 bytes)
One sheet, four cells: two texts, the number 42 and the formula
=A3*2. It's the file in the anatomy above.- Learning the BIFF8 record structure
- Smoke tests for XLS readers
Edge cases and limits
sample-edge-cases.xls · 43 KB (44,032 bytes)
Leading zeros, a 16-digit number as text and as a number, a boolean, a
#DIV/0!error, serials 1, 59, 60 and 61 with a date format, a time, emoji and non-Latin text, a hyperlink, a note, merged cells, a 32,767-character cell, a hidden sheet, and a sheet with values in all four corner cells, A1 to IV65536.- Checking how a library reads unusual cells
- Testing readers at the 65,536 × 256 limit
Password-protected XLS (password: 99helpers)
sample-password.xls · 6 KB (6,144 bytes)
Encrypted with 40-bit RC4, announced by a FILEPASS record right after the first BOF record. The password is
99helpers. The cells are encrypted; the document properties are not.- Testing how uploads and converters treat encrypted workbooks
- Checking error messages in import code
1 MB XLS file
sample-1mb.xls · 1 MB (1,048,576 bytes)
9,523 rows of fictional orders on one sheet, plus a filler cell on a second sheet that brings the file to exactly 1,048,576 bytes (1 MiB).
- Upload and size-limit tests
- Import performance
Ways to test with them
- Formula results: a reader should report
25in Orders!G2 ofsample-workbook.xlsand255.07in G14, the total, without recalculating. - Dates: Orders!B2 holds 46296 with a date format; converted with the workbook's date mode it must be 1 October 2026.
- Size limits: the Limits sheet of
sample-edge-cases.xlsuses cell IV65536, so its used range is the whole 65,536 × 256 grid. A reader that allocates every cell up front will use a lot of memory. - Encrypted files:
xlrdrefusessample-password.xlswith "Workbook is encrypted". Your import should report that clearly, not crash or import nothing silently. - Upload limits:
sample-1mb.xlsis exactly 1,048,576 bytes, so you can test a limit right at the boundary.
Free to use for testing, teaching and demos, commercially or not, with no attribution needed. A link back to this page is always appreciated.
Put it online
Have an XLS file? Give it a link.
Drop an Excel 97-2003 workbook on 99helpers and it gets its own web address. Browsers can't display XLS files, so anyone with the link downloads it and opens it in Excel, LibreOffice, Google Sheets or Numbers.
Questions
XLS files, frequently asked
What is an XLS file?
An Excel workbook in the binary format of Excel 97 to 2003, called BIFF8. Excel 2007 and later save XLSX by default but still open and save XLS.
What's the difference between XLS and XLSX?
XLS is binary and limited to 65,536 rows and 256 columns per sheet. XLSX is a ZIP of XML with 1,048,576 rows and 16,384 columns, smaller files and an open standard. An XLS can contain macros; an XLSX can't.
How many rows can an XLS file have?
65,536 rows and 256 columns per sheet. Anything beyond that is lost when a workbook is saved as XLS.
How do I open an XLS file without Excel?
Use LibreOffice Calc (free), Google Sheets (upload the file to Google Drive), Numbers on Apple devices, or Excel for the web, which is free with a Microsoft account.
How do I convert XLS to XLSX?
Open it in Excel and choose File, Save As, Excel Workbook (.xlsx). LibreOffice does it too: soffice --headless --convert-to xlsx file.xls.
Why does Excel say the file format and extension don't match?
The file isn't a real XLS: usually an HTML table or CSV file saved with an .xls name by a web app. If you trust the source, open it and save it as XLSX.
Can an XLS file contain a virus?
Yes. XLS files can hold VBA macros and old Excel 4.0 macros, and both have been used to spread malware. Don't enable content in a spreadsheet you didn't expect.
Can Python read XLS files?
Yes. xlrd reads them, and pandas uses it for pd.read_excel("file.xls"). To write XLS, convert from XLSX with LibreOffice; few maintained libraries still write the format.
Related formats
Other file types explained
Keep going
Related
Sources
- Microsoft: [MS-XLS] Excel Binary File Format (.xls) Structure
- Library of Congress: Excel 97-2003 Binary File Format (BIFF8)
- Microsoft: Use Excel with earlier versions of Excel
- Microsoft: [MS-CFB] Compound File Binary File Format
- Microsoft Learn: Macros from the internet are blocked by default in Office
- Redmond Magazine: Excel 4.0 (XLM) macros blocked by default
Last reviewed 27 October 2026.