{"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":"en","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,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}