{"id":25842064,"url":"https://github.com/kz26/pyexcelerate","last_synced_at":"2025-05-15T12:06:54.811Z","repository":{"id":7998108,"uuid":"9405260","full_name":"kz26/PyExcelerate","owner":"kz26","description":"Accelerated Excel XLSX Writing Library for Python 2/3","archived":false,"fork":false,"pushed_at":"2025-04-18T00:21:56.000Z","size":617,"stargazers_count":552,"open_issues_count":24,"forks_count":62,"subscribers_count":29,"default_branch":"dev","last_synced_at":"2025-05-15T12:06:46.722Z","etag":null,"topics":["excel","excelwriter","library","python","python3","xlsx"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/PyExcelerate/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kz26.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2013-04-12T22:48:05.000Z","updated_at":"2025-05-13T16:26:05.000Z","dependencies_parsed_at":"2023-02-19T03:00:30.942Z","dependency_job_id":"f2f20e27-56d6-4aa4-ac2e-ff4789cc07ad","html_url":"https://github.com/kz26/PyExcelerate","commit_stats":{"total_commits":405,"total_committers":22,"mean_commits":18.40909090909091,"dds":0.5234567901234568,"last_synced_commit":"09f35a5a10459bdad59ea3e2f8ea4916e6ae901e"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kz26%2FPyExcelerate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kz26%2FPyExcelerate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kz26%2FPyExcelerate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kz26%2FPyExcelerate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kz26","download_url":"https://codeload.github.com/kz26/PyExcelerate/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337616,"owners_count":22054254,"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","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":["excel","excelwriter","library","python","python3","xlsx"],"created_at":"2025-03-01T05:33:59.126Z","updated_at":"2025-05-15T12:06:49.802Z","avatar_url":"https://github.com/kz26.png","language":"Python","readme":"# PyExcelerate\n\nAccelerated Excel XLSX writing library for Python\n\n[![coverage-status](https://coveralls.io/repos/kz26/PyExcelerate/badge.svg)](https://coveralls.io/r/kz26/PyExcelerate) \n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyexcelerate)\n![PyPI - Version](https://img.shields.io/pypi/v/pyexcelerate)\n\n* Authors: [Kevin Wang](https://github.com/kevmo314) and [Kevin Zhang](https://github.com/kz26)\n* Copyright 2015 Kevin Wang, Kevin Zhang. Portions copyright Google, Inc.\n* License: Simplified BSD License\n* [Source repository](https://github.com/kz26/PyExcelerate)\n* [PyPI page](https://pypi.python.org/pypi/PyExcelerate)\n\n## Description\n\nPyExcelerate is a Python for writing Excel-compatible XLSX spreadsheet files, with an emphasis\non speed.\n\n### Benchmarks\nBenchmark code located in pyexcelerate/tests/benchmark.py   \nUbuntu 12.04 LTS, Core i5-3450, 8GB DDR3, Python 2.7.3\n\n```\n|          TEST_NAME          | NUM_ROWS | NUM_COLS | TIME_IN_SECONDS |\n|-----------------------------|----------|----------|-----------------|\n| pyexcelerate value fastest  |     1000 |      100 |            0.47 |\n| pyexcelerate value faster   |     1000 |      100 |            0.51 |\n| pyexcelerate value fast     |     1000 |      100 |            1.53 |\n| xlsxwriter value            |     1000 |      100 |            0.84 |\n| openpyxl                    |     1000 |      100 |            2.74 |\n| pyexcelerate style cheating |     1000 |      100 |            1.23 |\n| pyexcelerate style fastest  |     1000 |      100 |            2.40 |\n| pyexcelerate style faster   |     1000 |      100 |            2.75 |\n| pyexcelerate style fast     |     1000 |      100 |            6.15 |\n| xlsxwriter style cheating   |     1000 |      100 |            1.21 |\n| xlsxwriter style            |     1000 |      100 |            4.85 |\n| openpyxl                    |     1000 |      100 |            6.32 |\n\n* cheating refers to pregeneration of styles\n\n```\n\n## Installation\n\nPyExcelerate is supported on Python 2.7, 3.4, 3.5, 3.6, 3.7, and 3.8.\n\n    pip install pyexcelerate\n\n## Usage\n\n### Writing bulk data\n\n#### Fastest\n\n```python\nfrom pyexcelerate import Workbook\n\ndata = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # data is a 2D array\n\nwb = Workbook()\nwb.new_sheet(\"sheet name\", data=data)\nwb.save(\"output.xlsx\")\n\n```\n\n### Writing bulk data to a range\n\nPyExcelerate also permits you to write data to ranges directly, which is faster than writing cell-by-cell. If writing a Pandas DataFrame, see the [note on compatibility](#Pandas-DataFrames).\n\n#### Fastest\n\n```python\nfrom pyexcelerate import Workbook\n\nwb = Workbook()\nws = wb.new_sheet(\"test\", data=[[1, 2], [3, 4]])\nwb.save(\"output.xlsx\")\n```\n\n#### Fast\n\n```python\nfrom pyexcelerate import Workbook\n\nwb = Workbook()\nws = wb.new_sheet(\"test\")\nws.range(\"B2\", \"C3\").value = [[1, 2], [3, 4]]\nwb.save(\"output.xlsx\")\n```\n\n### Writing cell data\n\n#### Faster\n\n```python\nfrom datetime import datetime\nfrom pyexcelerate import Workbook\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws.set_cell_value(1, 1, 15) # a number\nws.set_cell_value(1, 2, 20)\nws.set_cell_value(1, 3, \"=SUM(A1,B1)\") # a formula\nws.set_cell_value(1, 4, datetime.now()) # a date\nwb.save(\"output.xlsx\")\n```\n\n#### Fast\n\n```python\nfrom datetime import datetime\nfrom pyexcelerate import Workbook\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws[1][1].value = 15 # a number\nws[1][2].value = 20\nws[1][3].value = \"=SUM(A1,B1)\" # a formula\nws[1][4].value = datetime.now() # a date\nwb.save(\"output.xlsx\")\n```\n\n### Selecting cells by name\n\n```python\nfrom pyexcelerate import Workbook\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws.cell(\"A1\").value = 12\nwb.save(\"output.xlsx\")\n```\n\n### Merging cells\n\n```python\nfrom pyexcelerate import Workbook\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws[1][1].value = 15\nws.range(\"A1\", \"B1\").merge()\nwb.save(\"output.xlsx\")\n```\n\n### Styling cells\n\nStyling cells causes **non-negligible** overhead. It **will** increase your execution time (up to 10x longer if done improperly!). Only style cells if absolutely necessary.\n\n#### Fastest\n\n```python\nfrom pyexcelerate import Workbook, Color, Style, Font, Fill, Format\nfrom datetime import datetime\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws.set_cell_value(1, 1, 1)\nws.set_cell_style(1, 1, Style(font=Font(bold=True)))\nws.set_cell_style(1, 1, Style(font=Font(italic=True)))\nws.set_cell_style(1, 1, Style(font=Font(underline=True)))\nws.set_cell_style(1, 1, Style(font=Font(strikethrough=True)))\nws.set_cell_style(1, 1, Style(fill=Fill(background=Color(255,0,0,0))))\nws.set_cell_value(1, 2, datetime.now())\nws.set_cell_style(1, 1, Style(format=Format('mm/dd/yy')))\nwb.save(\"output.xlsx\")\n```\n\nNote that in this example, subsequent calls to `set_cell_style()` override the previous styles and they are not merged in. To have a combined style, create a single `Style` object with multiple properties, for example\n\n```\nws.set_cell_style(1, 1, Style(font=Font(bold=True), format=Format('mm/dd/yy')))\n```\n\n#### Faster\n\n```python\nfrom pyexcelerate import Workbook, Color\nfrom datetime import datetime\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws.set_cell_value(1, 1, 1)\nws.get_cell_style(1, 1).font.bold = True\nws.get_cell_style(1, 1).font.italic = True\nws.get_cell_style(1, 1).font.underline = True\nws.get_cell_style(1, 1).font.strikethrough = True\nws.get_cell_style(1, 1).fill.background = Color(0, 255, 0, 0)\nws.set_cell_value(1, 2, datetime.now())\nws.get_cell_style(1, 1).format.format = 'mm/dd/yy'\nwb.save(\"output.xlsx\")\n```\n#### Fast\n\n```python\nfrom pyexcelerate import Workbook, Color\nfrom datetime import datetime\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws[1][1].value = 1\nws[1][1].style.font.bold = True\nws[1][1].style.font.italic = True\nws[1][1].style.font.underline = True\nws[1][1].style.font.strikethrough = True\nws[1][1].style.fill.background = Color(0, 255, 0, 0)\nws[1][2].value = datetime.now()\nws[1][2].style.format.format = 'mm/dd/yy'\nwb.save(\"output.xlsx\")\n```\n\n**Note** that `.style.format.format`'s repetition is due to planned support for conditional formatting and other related features. The formatting syntax may be improved in the future.\n\n### Styling ranges\n\n```python\nfrom pyexcelerate import Workbook, Color\nfrom datetime import datetime\n\nwb = Workbook()\nws = wb.new_sheet(\"test\")\nws.range(\"A1\",\"C3\").value = 1\nws.range(\"A1\",\"C1\").style.font.bold = True\nws.range(\"A2\",\"C3\").style.font.italic = True\nws.range(\"A3\",\"C3\").style.fill.background = Color(255, 0, 0, 0)\nws.range(\"C1\",\"C3\").style.font.strikethrough = True\n```\n\n### Styling rows\n\nA simpler (and faster) way to style an entire row.\n\n#### Fastest\n\n```python\nfrom pyexcelerate import Workbook, Color, Style, Fill\nfrom datetime import datetime\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws.set_row_style(1, Style(fill=Fill(background=Color(255,0,0,0))))\nwb.save(\"output.xlsx\")\n```\n\n#### Faster\n\n```python\nfrom pyexcelerate import Workbook, Color\nfrom datetime import datetime\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws.get_row_style(1).fill.background = Color(255, 0, 0)\nwb.save(\"output.xlsx\")\n\n```\n\n#### Fast\n\n```python\nfrom pyexcelerate import Workbook, Color\nfrom datetime import datetime\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws[1].style.fill.background = Color(255, 0, 0)\nwb.save(\"output.xlsx\")\n```\n\n### Styling columns\n\n#### Fastest\n\n```python\nfrom pyexcelerate import Workbook, Color, Style, Fill\nfrom datetime import datetime\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws.set_col_style(1, Style(fill=Fill(background=Color(255,0,0,0))))\nwb.save(\"output.xlsx\")\n```\n\n### Available style attributes\n\nConsistent with the implementation patterns above, the following style parameters are available:\n\n```python\nws[1][1].style.font.bold = True\nws[1][1].style.font.italic = True\nws[1][1].style.font.underline = True\nws[1][1].style.font.strikethrough = True\nws[1][1].style.font.color = Color(255, 0, 255)\nws[1][1].style.fill.background = Color(0, 255, 0)\nws[1][1].style.alignment.vertical = 'top'\nws[1][1].style.alignment.horizontal = 'right'\nws[1][1].style.alignment.rotation = 90\nws[1][1].style.alignment.wrap_text = True\nws[1][1].style.borders.top.color = Color(255, 0, 0)\nws[1][1].style.borders.right.style = '-.'\nws[1][1].style.data_type = DataTypes.INLINE_STRING\nws[1][1].style.quote_prefix = True\n```\n\nEach attribute also has constructors for implementing via `set_cell_style()`.\n\nThe following border styles are available: `.-`, `..-`, `--`, `..`, `=`, `.`, `medium -.`, `medium -..`, `medium --`, `/-.`, `_`\n\n### Setting row heights and column widths\n\nRow heights and column widths are set using the `size` attribute in `Style`. Appropriate values are:\n*\t`-1` for auto-fit\n*\t`0` for hidden\n*\tAny other value for the appropriate size.\n\nFor example, to hide column B:\n\n```python\nfrom pyexcelerate import Workbook, Color, Style, Fill\nfrom datetime import datetime\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws.set_col_style(2, Style(size=0))\nwb.save(\"output.xlsx\")\n```\n\n### Linked styles\n\nPyExcelerate supports using style objects instead manually setting each attribute as well. This permits you to modify the style at a later time.\n\n```python\nfrom pyexcelerate import Workbook, Font\n\nwb = Workbook()\nws = wb.new_sheet(\"sheet name\")\nws[1][1].value = 1\nfont = Font(bold=True, italic=True, underline=True, strikethrough=True)\nws[1][1].style.font = font\nwb.save(\"output.xlsx\")\n```\n\n## Pandas DataFrames\n\nPyExcelerate does not support directly passing a Pandas DataFrame as the data argument to a new worksheet. If the sheet does not require having the headers rendered, the most efficient solution is:\n\n```python\nws = wb.new_sheet(\"sheet name\", data=df.values.tolist())\n```\n\nNote that the conversion `.tolist()` is faster as PyExcelerate has some optimizations surrounding data that's provided in lists. If the sheet needs to have headers rendered, consider [asking the Pandas maintainers](https://github.com/pandas-dev/pandas/issues/4517) to integrate PyExcelerate, [use a transformation function](https://gist.github.com/mapa17/bc04be36e447cab0746a0ec8903cc49f), or convert your DataFrame to a list with the headers included.\n\n## Packaging with PyInstaller\n\nPyInstaller is the only packager officially supported by PyExcelerate. Copy hook-pyexcelerate.Writer.py to your PyInstaller hooks directory.\n\n\n## Support\nPlease use the GitHub Issue Tracker and pull request system to report bugs/issues and submit improvements/changes, respectively.  **Pull requests *must* be based against the dev branch - if not, we will reject the PR and ask you to rebase against the correct branch.** All nontrivial changes to code should be accompanied by a test when appropriate. We use the Nose testing framework.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkz26%2Fpyexcelerate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkz26%2Fpyexcelerate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkz26%2Fpyexcelerate/lists"}