{"id":24333134,"url":"https://github.com/rahmadafandi/rustpy-xlsxwriter","last_synced_at":"2026-02-08T15:04:23.822Z","repository":{"id":270529309,"uuid":"910660841","full_name":"rahmadafandi/rustpy-xlsxwriter","owner":"rahmadafandi","description":"Rust Python bindings for rust_xlsxwriter","archived":false,"fork":false,"pushed_at":"2025-04-08T12:18:22.000Z","size":271,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-01T07:51:25.345Z","etag":null,"topics":["maturin","pyo3","python","python-3","rust","xlsx","xlsxwriter"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/rustpy-xlsxwriter/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rahmadafandi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-01T01:05:38.000Z","updated_at":"2025-08-29T03:57:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"5c527eeb-df02-4173-9731-9e665553141b","html_url":"https://github.com/rahmadafandi/rustpy-xlsxwriter","commit_stats":null,"previous_names":["rahmadafandi/rustpy-xlsxwriter"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/rahmadafandi/rustpy-xlsxwriter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahmadafandi%2Frustpy-xlsxwriter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahmadafandi%2Frustpy-xlsxwriter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahmadafandi%2Frustpy-xlsxwriter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahmadafandi%2Frustpy-xlsxwriter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rahmadafandi","download_url":"https://codeload.github.com/rahmadafandi/rustpy-xlsxwriter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahmadafandi%2Frustpy-xlsxwriter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001646,"owners_count":26083147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["maturin","pyo3","python","python-3","rust","xlsx","xlsxwriter"],"created_at":"2025-01-18T03:13:21.576Z","updated_at":"2025-10-09T15:35:45.505Z","avatar_url":"https://github.com/rahmadafandi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RustPy-XlsxWriter\n\n[![PyPI version](https://badge.fury.io/py/rustpy-xlsxwriter.svg)](https://badge.fury.io/py/rustpy-xlsxwriter)\n[![Python Versions](https://img.shields.io/pypi/pyversions/rustpy-xlsxwriter.svg)](https://pypi.org/project/rustpy-xlsxwriter/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Downloads](https://pepy.tech/badge/rustpy-xlsxwriter)](https://pepy.tech/project/rustpy-xlsxwriter)\n[![CI](https://github.com/rahmadafandi/rustpy-xlsxwriter/actions/workflows/CI.yml/badge.svg)](https://github.com/rahmadafandi/rustpy-xlsxwriter/actions/workflows/CI.yml)\n\nRustPy-XlsxWriter is a high-performance library for generating Excel files in Python, powered by Rust and integrated using PyO3. This library is ideal for creating Excel files with large datasets efficiently while maintaining a simple and Pythonic interface.\n\n## Installation\n\nInstall RustPy-XlsxWriter via pip:\n\n```bash\npip install rustpy-xlsxwriter\n```\n\n## Features\n\n- Create Excel files quickly and efficiently.\n- Support for various data types including text, numbers, dates, and booleans.\n- Save data into multiple sheets.\n- Optionally protect Excel files with passwords.\n- Sheet name validation utilities.\n- Freeze panes support for better worksheet navigation.\n\n## Freeze Panes\n\nRustPy-XlsxWriter supports freezing rows and columns in worksheets to keep important data visible while scrolling. This feature is available for both single and multiple worksheet scenarios.\n\n### Single Worksheet\n\nFor a single worksheet, you can freeze rows and columns using the `freeze_row` and `freeze_col` parameters:\n\n```python\nfrom rustpy_xlsxwriter import write_worksheet\n\n# Freeze the first row (headers)\nwrite_worksheet(records, \"output.xlsx\", freeze_row=1)\n\n# Freeze both first row and first column\nwrite_worksheet(records, \"output.xlsx\", freeze_row=1, freeze_col=1)\n```\n\n### Multiple Worksheets\n\nFor multiple worksheets, you can configure freeze panes globally and/or per sheet using the `freeze_pane` parameter:\n\n```python\nfrom rustpy_xlsxwriter import write_worksheets\n\n# Configuration for freeze panes\nfreeze_config = {\n    \"general\": {\"row\": 1, \"col\": 0},  # Apply to all sheets\n    \"Sheet1\": {\"row\": 1, \"col\": 2},  # Override for Sheet1\n    \"Sheet2\": {\"row\": 2, \"col\": 1}   # Override for Sheet2\n}\n\nwrite_worksheets(\n    records_with_sheet_name,\n    \"output.xlsx\",\n    freeze_panes=freeze_config\n)\n```\n\nThe `freeze_panes` configuration allows you to:\n\n- Set a general configuration that applies to all sheets\n- Override the configuration for specific sheets\n- Freeze rows and columns independently\n\n## API Reference\n\nBelow is the API provided by `rustpy_xlsxwriter`:\n\n### `get_version()`\n\n```python\nfrom rustpy_xlsxwriter import get_version\n\ndef get_version() -\u003e str:\n    \"\"\"\n    Get the version of the RustPy-XlsxWriter library.\n\n    Returns:\n        str: The version string.\n    \"\"\"\n```\n\n### `write_worksheet()`\n\n```python\nfrom rustpy_xlsxwriter import write_worksheet\n\ndef write_worksheet(\n    records: List[Dict[str, Any]],\n    file_name: str,\n    sheet_name: Optional[str] = None,\n    password: Optional[str] = None,\n    freeze_row: Optional[int] = None,\n    freeze_col: Optional[int] = None,\n):\n    \"\"\"\n    Save records to a single sheet in an Excel file.\n\n    Args:\n        records: List of dictionaries where each dict represents a row of data.\n                Dictionary keys become column headers and values become cell contents.\n                Supported value types:\n                - str: Text values\n                - int/float: Numeric values\n                - bool: Boolean values\n                - None: Empty cells\n                - datetime.date/datetime.datetime: Date values\n        file_name: Full path including filename where the Excel file will be saved.\n                  Must have .xlsx extension.\n        sheet_name: Optional name for the worksheet. If not provided, defaults to 'Sheet1'.\n                   Must be \u003c= 31 chars and cannot contain [ ] : * ? / \\.\n        password: Optional password to protect the workbook from modifications.\n        freeze_row: Optional row index to freeze.\n        freeze_col: Optional column index to freeze.\n    \"\"\"\n```\n\n### `write_worksheets()`\n\n```python\nfrom rustpy_xlsxwriter import write_worksheets\n\ndef write_worksheets(\n    records_with_sheet_name: List[Dict[str, List[Dict[str, Any]]]],\n    file_name: str,\n    password: Optional[str] = None,\n    freeze_panes: Optional[Dict[str, Any]] = None,\n):\n    \"\"\"\n    Save records to multiple sheets in an Excel file.\n\n    Args:\n        records_with_sheet_name: List of dictionaries where each dict maps a sheet name to its records.\n                                The records for each sheet follow the same format as write_worksheet().\n                                Sheet names must be \u003c= 31 chars and cannot contain [ ] : * ? / \\.\n        file_name: Full path including filename where the Excel file will be saved.\n                  Must have .xlsx extension.\n        password: Optional password to protect the workbook from modifications.\n        freeze_panes: Optional configuration for freeze panes.\n                      If provided, it should be a dictionary with the following keys:\n                      - 'general': A dictionary with 'row' and 'col' keys for general freeze panes.\n                      - 'Sheet Name': A dictionary where keys are sheet names and values are dictionaries\n                                          with 'row' and 'col' keys for specific sheet freeze panes.\n    \"\"\"\n```\n\n### `validate_sheet_name()`\n\n```python\nfrom rustpy_xlsxwriter import validate_sheet_name\n\ndef validate_sheet_name(name: str) -\u003e bool:\n    \"\"\"\n    Validate if a sheet name is valid for Excel.\n\n    Args:\n        name: Sheet name to validate. Excel has several restrictions on valid sheet names:\n              - Maximum 31 characters\n              - Cannot contain characters: [ ] : * ? / \\\n              - Cannot be empty\n              - Cannot start or end with an apostrophe\n              - Cannot be 'History' (reserved name)\n\n    Returns:\n        bool: True if the sheet name is valid for Excel, False otherwise\n    \"\"\"\n```\n\n## Performance\n\n![Test Result](image.png)\n\nRustPy-XlsxWriter has been extensively tested with large-scale datasets to measure its performance capabilities. Our benchmarks demonstrate that this Rust-powered implementation delivers exceptional speed improvements compared to traditional Python solutions. The library achieves up to 6x faster processing speeds while maintaining optimal memory usage, making it ideal for handling large datasets efficiently.\n\nBased on performance testing with 1 million records:\n\n| Operation         | Records   | Time (seconds) | Comparison  |\n| ----------------- | --------- | -------------- | ----------- |\n| Single Sheet      | 1,000,000 | ~67.80s        | 5.4x faster |\n| Multiple Sheets   | 1,000,000 | ~61.19s        | 6x faster   |\n| Python xlsxwriter | 1,000,000 | ~364.46s       | baseline    |\n\nKey findings:\n\n- Demonstrates superior performance with 6x faster processing compared to Python's xlsxwriter\n- Efficiently handles single sheet operations for 1 million records\n- Maintains consistent performance for multiple sheet operations\n- Shows excellent scalability - performance improves proportionally with smaller datasets\n\nThe exceptional performance is achieved through several key optimizations:\n\n1. Leveraging Rust's zero-cost abstractions and memory management system\n2. Native machine code compilation for maximum efficiency\n3. Advanced memory optimization using rust_xlsxwriter capabilities\n4. High-precision floating point operations with ryu\n5. Efficient large file handling through zlib compression\n6. Memory safety guarantees via Rust's ownership system\n\nThese technical advantages ensure consistent high performance and reliability across varying workload sizes while maintaining optimal resource utilization.\n\n## Usage Examples\n\n### Write Records to a Single Sheet\n\n```python\nfrom rustpy_xlsxwriter import write_worksheet\nfrom datetime import datetime\n\nrecords = [\n    {\n        \"Name\": \"Alice\",\n        \"Age\": 30,\n        \"City\": \"New York\",\n        \"Active\": True,\n        \"Join Date\": datetime(2023, 1, 15)\n    },\n    {\n        \"Name\": \"Bob\",\n        \"Age\": 25,\n        \"City\": \"San Francisco\",\n        \"Active\": False,\n        \"Join Date\": datetime(2023, 2, 1)\n    },\n]\n\n# Basic usage\nwrite_worksheet(records, \"output.xlsx\", sheet_name=\"Sheet1\")\n\n# With freeze panes - freeze first row and first column\nwrite_worksheet(records, \"output_frozen.xlsx\", sheet_name=\"Sheet1\", freeze_row=1, freeze_col=1)\n```\n\n### Write Records to Multiple Sheets\n\n```python\nfrom rustpy_xlsxwriter import write_worksheets\n\nrecords_with_sheet_name = [\n    {\"Employees\": [\n        {\n            \"Name\": \"Alice\",\n            \"Age\": 30,\n            \"City\": \"New York\",\n            \"Active\": True\n        },\n        {\n            \"Name\": \"Bob\",\n            \"Age\": 25,\n            \"City\": \"San Francisco\",\n            \"Active\": False\n        },\n    ]},\n    {\"Inventory\": [\n        {\n            \"Product\": \"Laptop\",\n            \"Price\": 1000.0,\n            \"Stock\": 50,\n            \"Available\": True\n        },\n        {\n            \"Product\": \"Phone\",\n            \"Price\": 500.0,\n            \"Stock\": 100,\n            \"Available\": True\n        },\n    ]},\n]\n\n# Basic usage\nwrite_worksheets(records_with_sheet_name, \"output_multiple_sheets.xlsx\")\n\n# With freeze panes configuration\nfreeze_config = {\n    \"general\": {\"row\": 1, \"col\": 0},  # Apply to all sheets\n    \"Employees\": {\"row\": 1, \"col\": 2},  # Override for Employees sheet\n    \"Inventory\": {\"row\": 2, \"col\": 1}   # Override for Inventory sheet\n}\nwrite_worksheets(\n    records_with_sheet_name,\n    \"output_frozen.xlsx\",\n    freeze_pane=freeze_config\n)\n```\n\n## Contributing\n\nContributions are welcome! Please submit issues or pull requests on the [GitHub repository](https://github.com/rahmadafandi/rustpy-xlsxwriter).\n\n## License\n\nThis project is licensed under the MIT ![License](LICENSE).\n\n## Acknowledgements\n\nThis project is inspired by [Rust-XlsxWriter](https://github.com/jmcnamara/rust_xlsxwriter) and [PyO3](https://github.com/pyo3/pyo3) with the help of [maturin](https://github.com/PyO3/maturin).\n\n## Contributors\n\n- [Rahmad Afandi](https://github.com/rahmadafandi)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahmadafandi%2Frustpy-xlsxwriter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahmadafandi%2Frustpy-xlsxwriter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahmadafandi%2Frustpy-xlsxwriter/lists"}