{"id":4860,"library":"xlutils","title":"xlutils","description":"xlutils is a Python package offering various utilities for working with Excel files, specifically those compatible with `xlrd` and `xlwt`. It provides functionalities like copying `xlrd.Book` objects to `xlwt.Workbook` objects (xlutils.copy), displaying information, filtering, finding data margins, saving, and handling styles. The current version is 2.0.0. The library, along with its core dependencies `xlrd` and `xlwt`, is considered to be in maintenance mode or archived, with infrequent updates.","status":"maintenance","version":"2.0.0","language":"python","source_language":"en","source_url":"https://github.com/python-excel/xlutils","tags":["excel","xls","xlrd","xlwt","spreadsheet","utilities","legacy"],"install":[{"cmd":"pip install xlutils","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for reading Excel files. Version 0.6.1a1 or later.","package":"xlrd","optional":false},{"reason":"Required for writing Excel files. Version 0.7.0 or later.","package":"xlwt","optional":false},{"reason":"Required only if using xlutils.filter.ErrorFilter.","package":"errorhandler","optional":true}],"imports":[{"note":"The primary utility for copying xlrd.Book objects to xlwt.Workbook objects for modification.","symbol":"copy","correct":"from xlutils.copy import copy"},{"note":"Used in conjunction with `XLWTWriter` and `process` for advanced filtering and style preservation.","symbol":"XLRDReader","correct":"from xlutils.filter import process, XLRDReader, XLWTWriter"}],"quickstart":{"code":"import xlrd\nimport xlwt\nfrom xlutils.copy import copy\n\n# Create a dummy .xls file first for demonstration\nwb_initial = xlwt.Workbook()\nws_initial = wb_initial.add_sheet('Sheet1')\nws_initial.write(0, 0, 'Hello')\nws_initial.write(0, 1, 'World')\nws_initial.write(1, 0, 'Original Value')\nwb_initial.save('example_input.xls')\n\n# Open the existing workbook with xlrd\nrb = xlrd.open_workbook('example_input.xls', formatting_info=True)\n\n# Make a writable copy of the workbook using xlutils.copy\nwb = copy(rb)\n\n# Get the first sheet from the copied workbook\nws = wb.get_sheet(0)\n\n# Write a new value to a cell (e.g., cell B2)\nws.write(1, 1, 'Modified Value')\n\n# Save the modified workbook to a new .xls file\nwb.save('example_output.xls')\n\nprint(\"Modified workbook saved as 'example_output.xls'\")\n\n# Clean up dummy file (optional)\nimport os\nos.remove('example_input.xls')\nos.remove('example_output.xls')\n","lang":"python","description":"This quickstart demonstrates how to use `xlutils.copy` to open an existing Excel file (in `.xls` format), make modifications to a cell, and save the changes to a new file. It first creates a dummy `.xls` file to ensure the example is runnable. `formatting_info=True` is crucial for attempting to preserve styles during the copy operation."},"warnings":[{"fix":"Ensure input files are in `.xls` format. For `.xlsx` files, consider migrating to `openpyxl`.","message":"xlrd version 2.0.0 and later no longer supports `.xlsx` files due to security vulnerabilities related to parsing. Since `xlutils` relies on `xlrd` for reading, it is effectively limited to `.xls` files for input. Attempting to open an `.xlsx` file will result in an error.","severity":"breaking","affected_versions":"xlrd >= 2.0.0 (and thus xlutils using this version or later)"},{"fix":"For new projects, prefer `openpyxl`. For existing projects using `xlutils` and requiring `.xlsx` support, consider migrating.","message":"xlutils, xlrd, and xlwt are largely unmaintained or in archive status on GitHub. `xlrd` itself advises users to use `openpyxl` for modern Excel file formats (`.xlsx`). It is recommended to use `openpyxl` for new projects or when working with `.xlsx` files.","severity":"deprecated","affected_versions":"All versions"},{"fix":"For precise style preservation or modification, refer to `xlutils.filter` documentation or community solutions, often involving `XLRDReader` and `XLWTWriter`.","message":"Directly copying cell style information from an `xlrd.Book` object to an `xlwt.Workbook` object is complex. `xlrd` and `xlwt` use different internal representations for cell formatting (`XF` objects). While `xlutils.copy` attempts to preserve basic formatting, detailed style manipulation often requires using `xlutils.filter` with custom logic or a specific workaround.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure column indices are within the valid range (0-255). If more columns are needed, consider using a library like `openpyxl` that supports newer `.xlsx` formats with larger sheet dimensions.","message":"When writing to an Excel sheet using `xlwt` (and by extension `xlutils.copy`), column indices are limited to a range of 0-255 (corresponding to columns A through IV in Excel 2003 `.xls` format). Attempting to write to a column index outside this range will raise a `ValueError`.","severity":"gotcha","affected_versions":"All versions (due to underlying xlwt limitations)"}],"env_vars":null,"search_vec":"'2.0.0':47 'along':50 'archiv':66 'compat':17 'consid':59 'copi':26 'core':53 'current':44 'data':37 'depend':54 'display':33 'excel':13,70 'file':14 'filter':35 'find':36 'function':24 'handl':41 'inform':34 'infrequ':68 'legaci':76 'librari':49 'like':25 'mainten':63 'margin':38 'mode':64 'object':28,31 'offer':7 'packag':6 'provid':23 'python':5 'save':39 'specif':15 'spreadsheet':74 'style':42 'updat':69 'util':9,75 'various':8 'version':45 'work':11 'xlrd':19,55,72 'xlrd.book':27 'xls':71 'xlutil':1,2 'xlutils.copy':32 'xlwt':21,57,73 'xlwt.workbook':30","created_at":"2026-04-12T14:10:41.539322+00:00","updated_at":"2026-04-17T00:54:55.101394+00:00","problems":[{"fix":"Use a library specifically designed for `.xlsx` files, such as `openpyxl`, instead of `xlutils`.","cause":"`xlutils` (and its underlying dependency `xlrd`) is designed exclusively for the older `.xls` (BIFF) file format and cannot process newer `.xlsx` (OOXML) files.","error":"xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Saw 0x00000000000000000000000000000000 but expected 0x0002000000000600"},{"fix":"For datasets exceeding 65,536 rows, you must switch to the `.xlsx` format and use a library like `openpyxl`.","cause":"The `.xls` file format, which `xlutils` utilizes via `xlwt` for writing, has a strict limit of 65,536 rows per worksheet.","error":"ValueError: row index must be less than 65536"},{"fix":"Install the package using pip: `pip install xlutils`","cause":"The `xlutils` package has not been installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'xlutils'"},{"fix":"Downgrade your `xlrd` installation to a version prior to 2.0.0 (e.g., `pip install xlrd==1.2.0`) or avoid `xlutils` operations that require reading or copying formatting information.","cause":"`xlutils` operations that preserve or access cell formatting rely on `xlrd`'s `formatting_info` functionality, which was removed for security reasons in `xlrd` versions 2.0.0 and newer.","error":"NotImplementedError: formatting_info=True not yet implemented for .xls files"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.0.0","cli_name":"","cli_version":null,"type":"library","homepage":"http://www.python-excel.org","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/xlutils/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}