Registry / data / xlwt
library1.3.0pypypi✓ verified 26d ago

xlwt is a Python library for generating spreadsheet files compatible with MS Excel 97/2000/XP/2003 XLS files. It operates on any platform and supports Python 2.6, 2.7, and 3.3+. The current version is 1.3.0, released in 2017, and the project is effectively feature-frozen and no longer actively maintained.

pip install xlwt
INSTALL
IMPORT
SIG · XLWT
X
xlwt
datapythonv1.3.0
Install
1.8s avg
Import
61ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.064s · 18.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.058s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Workbook
import xlwt workbook = xlwt.Workbook()
The primary class for creating an Excel workbook.
easyxf
import xlwt style = xlwt.easyxf('font: bold on')
A convenient function for creating cell styles.

This quickstart demonstrates how to create a new Excel .xls workbook, add a sheet, write data to cells, apply basic styling, and save the file. Remember that xlwt only produces the older .xls format.

import xlwt # Create a new workbook workbook = xlwt.Workbook() # Add a sheet sheet = workbook.add_sheet('Sheet1') # Write some data to cells sheet.write(0, 0, 'Name') sheet.write(0, 1, 'Age') sheet.write(1, 0, 'Alice') sheet.write(1, 1, 30) # Add some styling style = xlwt.easyxf('font: bold on; align: horiz center') sheet.write(2, 0, 'Bob', style) sheet.write(2, 1, 24, style) # Save the workbook file_path = 'example.xls' try: workbook.save(file_path) print(f'Successfully created {file_path}') except Exception as e: print(f'Error saving workbook: {e}')
Debug
Known issues
breakingxlwt only supports the legacy .xls file format (Excel 97-2003). It cannot read or write the modern .xlsx format (Excel 2007+).
fix
For .xlsx files, use `openpyxl` (read/write) or `xlsxwriter` (write only) instead. If you strictly need .xls, then xlwt is suitable, but be aware of its limitations.
affects: All versions
deprecatedThe xlwt library is no longer actively maintained and is considered feature-frozen. It has been largely superseded by more modern libraries for Excel file manipulation.
fix
For new projects, consider using `openpyxl` for reading and writing .xlsx files, or `xlsxwriter` for writing .xlsx files. These libraries support modern Excel formats and features.
affects: All versions
gotchaDue to the underlying .xls format, xlwt is limited to 65,536 rows and 256 columns per sheet. Exceeding these limits will result in errors.
fix
Ensure your data fits within the .xls format limitations. For larger datasets, you must use a library that supports the .xlsx format (e.g., `openpyxl`), which has much higher limits (over 1 million rows, 16k columns).
affects: All versions
gotchaxlwt does not support many advanced Excel features such as charts, pivot tables, macros, or more complex conditional formatting, which are common in modern spreadsheets.
fix
If advanced Excel features are required, `xlsxwriter` (for writing) or `openpyxl` (for reading/writing) are better alternatives, as they offer more extensive feature sets for the .xlsx format.
affects: All versions
Errors
Common errors & fixes
ImportError: No module named xlwt
The xlwt library is not installed in the Python environment you are using.
fix
pip install xlwt
xlwt.exceptions.StringTooLongException: String too long (65536 characters)
You attempted to write a string longer than Excel's maximum cell string length (65535 characters for XLS files).
fix
Truncate the string to a maximum of 65535 characters before writing it to the cell.
TypeError: write() takes at most 4 arguments (5 given)
You passed too many arguments to the `worksheet.write()` method, often by incorrectly specifying a cell style or other parameters.
fix
Ensure the `write` method is called with `worksheet.write(row, col, label)` or `worksheet.write(row, col, label, style)`, where `style` is an `XFStyle` object.
AttributeError: 'Workbook' object has no attribute 'add_sheet'
The method name for adding a new sheet to a workbook was misspelled or incorrectly cased.
fix
Use the correct method name `workbook.add_sheet('Sheet Name')`.
Upgrade
Version history
1.3.0latest on PyPI · released Aug 22, 2017
Audit
Dependencies

No dependency data recorded yet.

Agent activity
49 hits · last 30 days
node
42
OpenAI (training)
1
Resources
xlwt — pip install xlwt · libregistry