File types · Explainer

The XLS file (.xls)

An XLS file is a Microsoft Excel workbook in the binary format that Excel 97 to 2003 saved by default, known as BIFF8. This guide explains what's inside one, its limits, how it differs from XLSX, the risks worth knowing, and has free sample XLS files to download for testing.

At a glance

Full name
Excel 97-2003 Workbook (Binary Interchange File Format 8, BIFF8)
Extensions
.xls; templates use .xlt, add-ins .xla
MIME type
application/vnd.ms-excel
Kind
Binary: BIFF8 records in a Workbook stream inside an OLE2 compound file
Owner
Microsoft; documented in the [MS-XLS] open specification
First released
1997, with Excel 97; Excel's default format until Excel 2007
Opens with
Excel, LibreOffice Calc, Google Sheets, Apple Numbers
Magic number
D0 CF 11 E0 A1 B1 1A E1 (any OLE2 file); the Workbook stream starts with a BOF record, 09 08 10 00 00 06 05 00
Sheet size
65,536 rows by 256 columns (A to IV)
Colours
A palette of 56 colours per workbook
Macros
Allowed: VBA, and old Excel 4.0 (XLM) macro sheets

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 .xlsx is 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.

sample-minimal.xls (hex and records)
$ 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. 1d0cf 11e0 a1b1 1ae1

    The 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. 2Workbook 1,815 bytes

    The Workbook stream

    All the cells, formats, sheets and charts. Excel 5.0 and 95 called this stream Book; a file with Book and no Workbook is the older BIFF5 format. Properties sit in the two summary streams, as in Word and PowerPoint files.

  3. 30809 BOF · 00 06 05 00

    Beginning of file

    0x0600 means BIFF8, and 0x0005 means 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. 40022 DATEMODE · 00 00

    The 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. 50031 FONT · 00e0 XF

    Fonts 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. 60085 BOUNDSHEET · e8 04 00 00

    A sheet entry

    The sheet's name, visibility and type, and where its substream starts: offset 0x04E8 in the stream. A hidden sheet has visibility 1, a very hidden one 2.

  7. 700fc 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 00 means 1 byte per character, 01 means UTF-16. Longer tables continue in CONTINUE records, since a BIFF8 record holds at most 8,224 bytes of data.

  8. 80200 DIMENSIONS

    The 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. 900fd LABELSST · 00 00 00 00 15 00 00 00 00 00

    A text cell

    Row 0, column 0 (A1), format 0x15 (bold), string 0 from the SST: "Hello, world."

  10. 10027e RK · aa 00 00 00

    A compact number

    RK records squeeze common numbers into 4 bytes. 0xAA has its "integer" bit set; shifted right by 2 it gives 42, the value of A3.

  11. 110006 FORMULA · 00 00 00 00 00 00 55 40

    A 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 rebuild A3*2 from 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 versionFormatHow to tell
Excel 2.x, 3.0, 4.0 (1987 to 1992)BIFF2, BIFF3, BIFF4A plain stream of records, not a compound file. Usually one sheet per file.
Excel 5.0 (1993) and Excel 95BIFF5A compound file with a Book stream; several sheets per workbook. Text in an 8-bit code page.
Excel 97 to 2003BIFF8A Workbook stream, BOF version 0x0600, Unicode text. This page's format.
Excel 97 to 2003, dual formatBIFF5 and BIFF8The "Excel 97 & 5.0/95 Workbook" option wrote both streams in one file, for colleagues on older versions.
Excel 2007 and laterXLSX by defaultA 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

Figures from Microsoft's comparison of Excel 97-2003 with Excel 2007 and later
XLS (Excel 97-2003)XLSX (Excel 2007 and later)
Rows × columns per sheet65,536 × 256 (IV)1,048,576 × 16,384 (XFD)
Unique cell formats4,00064,000
Nesting levels in a formula764
Arguments in a function30255
Characters in a formula1,0248,192
Conditional formatting conditions shown364
Sort levels364
ColoursThe 56-colour paletteAny 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

XLSXLSXXLSBODSCSV
StructureBIFF8 records in an OLE2 fileZIP of XMLZIP of binary partsZIP of XMLPlain text
Rows per sheet65,5361,048,5761,048,576Set by the app (LibreOffice: 1,048,576)No limit in the format
MacrosYes, same extensionNo (.xlsm instead)YesYesNo
Open standardDocumented, not a standardYes (ISO/IEC 29500)Documented, not a standardYes (ISO/IEC 26300)RFC 4180 (informational)
Formulas stored asCompiled tokensTextCompiled tokensTextValues 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 .xls name, as many web exports are. Open it in a text editor: a real XLS file is binary and starts with ÐÏ (the bytes D0 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 xlrd show 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, xlrd reads XLS (since version 2.0 it reads only XLS), and pandas uses it for .xls files. 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_Open or Auto_Open macro 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.

sample-workbook.xls · 13.5 KBDownload

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.

  1. 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.

  2. Order IDs as text

    000184 and the rest keep their leading zeros because they're text in the shared string table.

  3. Dates and currency

    Dates are serial numbers formatted yyyy-mm-dd; prices use a euro number format. The first date is stored as 46296.

  4. Formulas with cached results

    =E2*F2 on every row and SUM in the totals row, stored as compiled tokens with their results.

  5. 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.

  6. Summary sheet: SUMIF and a chart

    SUMIF formulas that read the Orders sheet, and a bar chart stored as BIFF8 chart records.

  7. 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 SUMIF formulas 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 25 in Orders!G2 of sample-workbook.xls and 255.07 in 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.xls uses 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: xlrd refuses sample-password.xls with "Workbook is encrypted". Your import should report that clearly, not crash or import nothing silently.
  • Upload limits: sample-1mb.xls is 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

Last reviewed 27 October 2026.