{"id":1791,"library":"xlwt","title":"xlwt","description":"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.","status":"deprecated","version":"1.3.0","language":"python","source_language":"en","source_url":"https://github.com/python-excel/xlwt","tags":["excel","xls","spreadsheet","data-export","legacy"],"install":[{"cmd":"pip install xlwt","lang":"bash","label":"Install xlwt"}],"dependencies":[],"imports":[{"note":"The primary class for creating an Excel workbook.","symbol":"Workbook","correct":"import xlwt\nworkbook = xlwt.Workbook()"},{"note":"A convenient function for creating cell styles.","symbol":"easyxf","correct":"import xlwt\nstyle = xlwt.easyxf('font: bold on')"}],"quickstart":{"code":"import xlwt\n\n# Create a new workbook\nworkbook = xlwt.Workbook()\n\n# Add a sheet\nsheet = workbook.add_sheet('Sheet1')\n\n# Write some data to cells\nsheet.write(0, 0, 'Name')\nsheet.write(0, 1, 'Age')\nsheet.write(1, 0, 'Alice')\nsheet.write(1, 1, 30)\n\n# Add some styling\nstyle = xlwt.easyxf('font: bold on; align: horiz center')\nsheet.write(2, 0, 'Bob', style)\nsheet.write(2, 1, 24, style)\n\n# Save the workbook\nfile_path = 'example.xls'\ntry:\n    workbook.save(file_path)\n    print(f'Successfully created {file_path}')\nexcept Exception as e:\n    print(f'Error saving workbook: {e}')\n","lang":"python","description":"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."},"warnings":[{"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.","message":"xlwt only supports the legacy .xls file format (Excel 97-2003). It cannot read or write the modern .xlsx format (Excel 2007+).","severity":"breaking","affected_versions":"All versions"},{"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.","message":"The 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.","severity":"deprecated","affected_versions":"All versions"},{"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).","message":"Due to the underlying .xls format, xlwt is limited to 65,536 rows and 256 columns per sheet. Exceeding these limits will result in errors.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"xlwt does not support many advanced Excel features such as charts, pivot tables, macros, or more complex conditional formatting, which are common in modern spreadsheets.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'1.3.0':34 '2.6':26 '2.7':27 '2017':37 '3.3':29 '97/2000/xp/2003':15 'activ':49 'compat':11 'current':31 'data':55 'data-export':54 'effect':42 'excel':14,51 'export':56 'featur':44 'feature-frozen':43 'file':10,17 'frozen':45 'generat':8 'legaci':57 'librari':6 'longer':48 'maintain':50 'ms':13 'oper':19 'platform':22 'project':40 'python':5,25 'releas':35 'spreadsheet':9,53 'support':24 'version':32 'xls':16,52 'xlwt':1,2","created_at":"2026-04-09T04:03:16.790747+00:00","updated_at":"2026-04-17T00:55:34.854421+00:00","problems":[{"fix":"pip install xlwt","cause":"The xlwt library is not installed in the Python environment you are using.","error":"ImportError: No module named xlwt"},{"fix":"Truncate the string to a maximum of 65535 characters before writing it to the cell.","cause":"You attempted to write a string longer than Excel's maximum cell string length (65535 characters for XLS files).","error":"xlwt.exceptions.StringTooLongException: String too long (65536 characters)"},{"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.","cause":"You passed too many arguments to the `worksheet.write()` method, often by incorrectly specifying a cell style or other parameters.","error":"TypeError: write() takes at most 4 arguments (5 given)"},{"fix":"Use the correct method name `workbook.add_sheet('Sheet Name')`.","cause":"The method name for adding a new sheet to a workbook was misspelled or incorrectly cased.","error":"AttributeError: 'Workbook' object has no attribute 'add_sheet'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.3.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/xlwt/","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-27","next_check":"2026-07-28","install_tag":null}}