{"id":3228,"library":"pyexcel-xls","title":"PyExcel XLS","description":"pyexcel-xls is a wrapper library designed to read, manipulate, and write data in the older Microsoft Excel XLS (Binary Interchange File Format) format. It functions primarily as a plugin for the `pyexcel` library, offering a unified API for spreadsheet data handling. The library is currently at version 0.7.1 and maintains an active, albeit sporadic, release cadence, typically tied to essential maintenance or updates of its core dependencies.","status":"active","version":"0.7.1","language":"en","source_language":"en","source_url":"https://github.com/pyexcel/pyexcel-xls","tags":["excel","xls","spreadsheet","pyexcel","data-processing"],"install":[{"cmd":"pip install pyexcel-xls","lang":"bash","label":"Install pyexcel-xls"}],"dependencies":[{"reason":"pyexcel-xls is a plugin for the main pyexcel library, providing a unified API for various Excel formats.","package":"pyexcel","optional":false},{"reason":"Required for reading .xls files. Version compatibility is crucial for .xlsx/.xlsm support (see warnings).","package":"xlrd","optional":false}],"imports":[{"note":"When used as a pyexcel plugin, explicit imports from pyexcel_xls are not needed; pyexcel auto-loads it.","symbol":"pyexcel.get_book","correct":"import pyexcel\nbook = pyexcel.get_book(file_name='your_file.xls')"},{"note":"The primary way to interact with .xls files via pyexcel's unified API.","symbol":"pyexcel.get_sheet","correct":"import pyexcel\nsheet = pyexcel.get_sheet(file_name='your_file.xls')"},{"note":"This is for standalone usage of pyexcel-xls without the main pyexcel library, but direct use of pyexcel is generally recommended.","wrong":"import pyexcel_xls.get_data","symbol":"get_data","correct":"from pyexcel_xls import get_data"},{"note":"This is for standalone usage of pyexcel-xls without the main pyexcel library, but direct use of pyexcel is generally recommended.","wrong":"import pyexcel_xls.save_data","symbol":"save_data","correct":"from pyexcel_xls import save_data"}],"quickstart":{"code":"import pyexcel\nfrom collections import OrderedDict\nimport os\n\n# Create some data\ndata = OrderedDict()\ndata.update({\"Sheet 1\": [[1, 2, 3], [4, 5, 6]]})\ndata.update({\"Sheet 2\": [[\"row 1\", \"row 2\", \"row 3\"]]})\n\n# Define a filename\nfile_name = \"my_data.xls\"\n\n# Write data to an XLS file\npyexcel.save_as(dest_file_name=file_name, adict=data)\nprint(f\"Data written to {file_name}\")\n\n# Read data from the XLS file\nbook = pyexcel.get_book(file_name=file_name)\nfor sheet in book:\n    print(f\"Sheet Name: {sheet.name}\")\n    for row in sheet:\n        print(row)\n\n# Clean up the created file\nos.remove(file_name)\nprint(f\"Cleaned up {file_name}\")","lang":"python","description":"This quickstart demonstrates how to use `pyexcel` (which leverages `pyexcel-xls` automatically) to write data to an `.xls` file and then read it back. It uses `OrderedDict` for structured sheet data and then saves and loads using `pyexcel.save_as` and `pyexcel.get_book` respectively."},"warnings":[{"fix":"For `.xlsx` or `.xlsm` files, install `pyexcel-xlsx` (`pip install pyexcel-xlsx`). `pyexcel-xlsx` uses `openpyxl` which properly handles these modern formats. If you specifically need `pyexcel-xls` to read `.xlsx` (though not recommended), you would have to pin `xlrd < 2.0.0` in your environment (e.g., `pip install 'xlrd<2.0.0' pyexcel-xls`).","message":"Starting with `v0.7.0`, `pyexcel-xls` removed its hard pin on `xlrd < 2.0`. If `xlrd` version 2.0.0 or greater is installed, `pyexcel-xls` will NO LONGER support reading `.xlsx` or `.xlsm` files. `v0.7.1` explicitly removed `.xlsm` support due to `xlrd>=2` changes.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Ensure your project runs on Python 3.6 or a more recent version.","message":"Version `0.6.0` dropped support for Python 2.x, requiring Python 3.6 or newer.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"For datasets larger than 65,536 rows, use the `.xlsx` format, which is supported by the `pyexcel-xlsx` library.","message":"The `.xls` (Excel 97-2003) file format has a hard limit of 65,536 rows and 256 columns per sheet. Attempting to write or read files exceeding these limits will result in errors or data loss.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Do not use `pyexcel-xls` if the preservation of visual formatting, styles, or formulas is a requirement. If only data extraction/insertion is needed, be aware that all such information will be lost upon saving.","message":"`pyexcel-xls` (and `pyexcel` in general) focuses solely on data content. It does not preserve or handle any formatting, styles, fonts, colors, charts, or formulas within the Excel file.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement post-processing logic to detect and handle these specific date/time interpretations if zero values in these fields are expected in your source data.","message":"When reading `.xls` files, zero values typed into DATE formatted fields are parsed as '01/01/1900', and zero values in TIME formatted fields are parsed as '00:00:00'.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}