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 xlwtVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
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).
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.
pip install xlwt
Truncate the string to a maximum of 65535 characters before writing it to the cell.
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.
Use the correct method name `workbook.add_sheet('Sheet Name')`.No dependency data recorded yet.