{"id":9326,"library":"spire-xls","title":"Spire.XLS for Python","description":"Spire.XLS for Python is a standalone Excel API designed for processing Excel files (XLS, XLSX, XLSB, XLSM, CSV) within Python applications. It allows developers to create, read, write, convert, and print Excel documents without requiring Microsoft Office. The current version is 16.4.0, and it maintains a regular release cadence with multiple updates annually.","status":"active","version":"16.4.0","language":"en","source_language":"en","source_url":"https://github.com/e-iceblue/spire.xls-for-python","tags":["excel","spreadsheet","office","xls","xlsx","data processing"],"install":[{"cmd":"pip install spire-xls","lang":"bash","label":"Install Spire.XLS"}],"dependencies":[],"imports":[{"symbol":"Workbook","correct":"from spire.xls import Workbook"},{"note":"Used for specifying file types during operations.","symbol":"FileFormat","correct":"from spire.xls import FileFormat"},{"note":"Used for specifying output file formats when saving.","symbol":"SaveFormat","correct":"from spire.xls import SaveFormat"}],"quickstart":{"code":"from spire.xls import Workbook, SaveFormat\n\n# Create a new workbook\nworkbook = Workbook()\n# Access the first worksheet (0-indexed)\nsheet = workbook.Worksheets[0]\n\n# Write data to cells using A1 notation\nsheet.Range[\"A1\"].Value = \"Hello, Spire.XLS!\"\nsheet.Range[\"B1\"].Value2 = 12345\n\n# Auto-fit columns\nsheet.AllocatedRange.AutoFitColumns()\n\n# Define the output file path\noutput_file = \"output_spire_xls_quickstart.xlsx\"\n\n# Save the workbook in XLSX format\nworkbook.SaveToFile(output_file, SaveFormat.Xlsx)\nworkbook.Dispose()\n\nprint(f\"Excel file saved to {output_file}\")","lang":"python","description":"This quickstart demonstrates how to create a new Excel workbook, write data to cells using A1 notation, auto-fit columns, and save the workbook as an XLSX file. The `Dispose()` method is called to release resources."},"warnings":[{"fix":"Ensure your Excel processing stays within the free evaluation limits (500 rows, 5 worksheets) or purchase a commercial license for full functionality.","message":"The free evaluation version of Spire.XLS for Python has significant limitations. It restricts operations to a maximum of 500 rows and 5 worksheets per Excel file (for both loading and saving). Exceeding these limits will raise an exception.","severity":"breaking","affected_versions":"All versions with a free evaluation tier."},{"fix":"For extremely large files, consider optimizing your logic to process data in chunks if applicable, or ensure your execution environment has sufficient RAM.","message":"Processing very large Excel files (e.g., hundreds of thousands of rows or complex formatting) can lead to high memory consumption, as the library often loads the entire document into memory.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Be mindful of the indexing scheme (0-based vs. 1-based) depending on whether you're using `Range[\"A1\"]` strings or direct collection access.","message":"While `sheet.Range[\"A1\"]` uses Excel's 1-based A1 notation, direct access to collection elements like `sheet.Worksheets`, `sheet.Rows`, and `sheet.Columns` uses 0-based indexing common in Python.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the package using `pip install spire-xls` in your project's virtual environment or global environment.","cause":"The `spire-xls` package is not installed in the active Python environment or the environment is not correctly activated.","error":"ModuleNotFoundError: No module named 'spire'"},{"fix":"Either reduce the size/complexity of the Excel files you are processing to fit within the 500-row/5-worksheet limit, or acquire and activate a commercial license from e-iceblue.","cause":"You are attempting to process an Excel file that exceeds the row or worksheet limits imposed by the free evaluation version of Spire.XLS for Python.","error":"System.ArgumentException: The free version of Spire.XLS for Python has a limitation of 500 rows and 5 worksheets for opening and writing."},{"fix":"Access cells using bracket notation for the `Range` property, e.g., `sheet.Range[\"A1\"].Value = \"data\"`.","cause":"You are attempting to call `Range` as a method (e.g., `sheet.Range(\"A1\")`) when it is an indexer property.","error":"AttributeError: 'Worksheet' object has no attribute 'Range'"},{"fix":"Ensure the `SaveFormat` enum matches the file extension. Use `SaveFormat.Xlsx` for `.xlsx` files and `SaveFormat.Xls` for `.xls` files.","cause":"There is a mismatch between the `SaveFormat` enumeration value provided to `SaveToFile` and the file extension specified in the output file path.","error":"System.ArgumentException: SaveFormat.Xls does not match the file extension .xlsx."}]}