A lightweight Python library for creating, reading, and modifying Excel files (.xlsx format) without requiring Microsoft Excel.
- Create & Edit Excel Files: Create new workbooks or modify existing .xlsx files
- Cell Operations: Read/write cell values, formulas, and apply formatting
- Styling: Apply fonts, colors, borders, number formats, and alignment
- Multiple Worksheets: Add, remove, and manage worksheets
- Data Validation: Add dropdown lists, number ranges, and custom validation rules
- Comments: Add and manage cell comments with author and rich text
- Hyperlinks: Create links to URLs, emails, files, and internal references
- Auto-Filters: Apply filtering to data ranges
- Conditional Formatting: Apply rules-based formatting
- CSV/JSON/Markdown Export: Save workbooks in multiple formats
- Encryption: Password-protect Excel files with AES encryption
- Workbook Protection: Protect workbook structure and worksheets
pip install aspose-cells-fossfrom aspose_cells import Workbook
# Create a new workbook
workbook = Workbook()
# Get the first worksheet
worksheet = workbook.worksheets[0]
# Set cell values
worksheet.cells["A1"].put_value("Hello")
worksheet.cells["B1"].put_value("World")
worksheet.cells["A2"].put_value(42)
worksheet.cells["B2"].put_value(3.14)
# Save the workbook
workbook.save("output.xlsx")from aspose_cells import Workbook
# Open an existing workbook
workbook = Workbook("input.xlsx")
# Access a worksheet
worksheet = workbook.worksheets[0]
# Read cell values
value = worksheet.cells["A1"].value
print(f"Cell A1 contains: {value}")from aspose_cells import Workbook
workbook = Workbook()
worksheet = workbook.worksheets[0]
cell = worksheet.cells["A1"]
cell.put_value("Styled Text")
# Get and modify the cell style
style = cell.get_style()
style.font.is_bold = True
style.font.color = "FF0000" # Red
style.font.size = 14
cell.set_style(style)
workbook.save("styled.xlsx")from aspose_cells import Workbook, DataValidationType
workbook = Workbook()
worksheet = workbook.worksheets[0]
# Add a dropdown list validation
validation = worksheet.data_validations.add()
validation.type = DataValidationType.LIST
validation.formula1 = '"Option1,Option2,Option3"'
validation.add_area("A1:A10")
workbook.save("validation.xlsx")from aspose_cells import Workbook, SaveFormat
workbook = Workbook("input.xlsx")
workbook.save("output.csv", SaveFormat.CSV)from aspose_cells import Workbook
workbook = Workbook()
worksheet = workbook.worksheets[0]
worksheet.cells["A1"].put_value("Confidential Data")
# Save with password protection
workbook.save("protected.xlsx", password="mypassword")
# Open a password-protected file
workbook2 = Workbook("protected.xlsx", password="mypassword")- Python 3.7 or higher
- pycryptodome >= 3.15.0
- olefile >= 0.46
For more examples and detailed API documentation, see the examples directory.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues