# pyfastexcel
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Zncl2222/pyfastexcel/go.yml?logo=go)
[![Go Report Card](https://goreportcard.com/badge/github.com/Zncl2222/pyfastexcel)](https://goreportcard.com/report/github.com/Zncl2222/pyfastexcel)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Zncl2222/pyfastexcel/pre-commit.yml?logo=pre-commit&label=pre-commit)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Zncl2222/pyfastexcel/codeql.yml?logo=github&label=CodeQL)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/03f42030775045b791586dee20288905)](https://app.codacy.com/gh/Zncl2222/pyfastexcel/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![codecov](https://codecov.io/gh/Zncl2222/pyfastexcel/graph/badge.svg?token=6I03AWUUWL)](https://codecov.io/gh/Zncl2222/pyfastexcel)
[![Documentation Status](https://readthedocs.org/projects/pyfastexcel/badge/?version=stable)](https://pyfastexcel.readthedocs.io/en/stable/?badge=stable)
This package enables high-performance Excel writing by integrating with the
streaming API from the golang package
[excelize](https://github.com/qax-os/excelize). Users can leverage this
functionality without the need to write any Go code, as the entire process
can be accomplished through Python.
## Features
- Python and Golang Integration: Seamlessly call Golang built shared
libraries from Python.
- No Golang Code Required: Users can solely rely on Python for Excel file
generation, eliminating the need for Golang expertise.
## Installation
### Install via pip (Recommended)
You can easily install the package via pip
```bash
pip install pyfastexcel
```
### Install manually
If you prefer to build the package manually, follow these steps:
1. Clone the repository:
```bash
git clone https://github.com/Zncl2222/pyfastexcel.git
```
2. Go to the project root directory:
```bash
cd pyfastexcel
```
3. Install the required golang packages:
```bash
go mod download
```
4. Build the Golang shared library using the Makefile:
```bash
make
```
5. Install the required python packages:
```bash
pip install -r requirements.txt
```
or
```bash
pipenv install
```
6. Import the project and start using it!
## Usage
The index assignment is now avaliable in `Workbook` and the `FastWriter`.
Here is the example usage:
```python
from pyfastexcel import Workbook
from pyfastexcel.utils import set_custom_style
# CustomStyle will be integrate to the pyfatexcel in next version
# Beside, CustomStyle will be re-implement in future to make it no-longer
# depend on openpyxl_style writer and openpyxl
from openpyxl_style_writer import CustomStyle
if __name__ == '__main__':
# Workbook
wb = Workbook()
# Set and register CustomStyle
bold_style = CustomStyle(font_size=15, font_bold=True)
set_custom_style('bold_style', bold_style)
ws = wb['Sheet1']
# Write value with default style
ws['A1'] = 'A1 value'
# Write value with custom style
ws['B1'] = ('B1 value', 'bold_style')
# Write value in slice with default style
ws['A2': 'C2'] = [1, 2, 3]
# Write value in slice with custom style
ws['A3': 'C3'] = [(1, 'bold_style'), (2, 'bold_style'), (3, 'bold_style')]
# Write value by row with default style (python index 0 is the index 1 in excel)
ws[3] = [9, 8, 'go']
# Write value by row with custom style
ws[4] = [(9, 'bold_style'), (8, 'bold_style'), ('go', 'bold_style')]
# Send request to golang lib and create excel
wb.read_lib_and_create_excel()
# File path to save
file_path = 'pyexample_workbook.xlsx'
wb.save(file_path)
```
You can also using the `FastWriter` or `NormalWriter` which was the
subclass of `Workbook` to write excel row by row, see the more in documentations [quickstart](https://pyfastexcel.readthedocs.io/en/stable/quickstart/).
## Documentation
The documentation is hosted on Read the Docs.
- [Development Version](https://pyfastexcel.readthedocs.io/en/latest/)
- [Latest Stable Version](https://pyfastexcel.readthedocs.io/en/stable/)
## Benchmark
The following result displays the performance comparison between
`pyfastexcel` and `openpyxl` for writing 50000 rows with 30
columns (Total 1500000 cells). To see more benchmark results, please
see the [benchmark](https://pyfastexcel.readthedocs.io/en/stable/benchmark/).
<dev align='center'>
<img src='./docs/images/50000_30_horizontal_Windows11.png' width="80%" height="45%" >
</dev>
## How it Works
The core functionality revolves around encoding Excel cell data and styles,
or any other Excel properties, into a JSON string within Python. This JSON
payload is then passed through ctypes to a Golang shared library. In Golang,
the JSON is parsed, and using the streaming writer of
[excelize](https://github.com/qax-os/excelize) to wrtie excel in
high performance.
## Current Limitations & Future Plans
### Problem 1: Dependence on Other Excel Package
Limitations:
This project currently depends on the `CustomStyle` object of
the [openpyxl_style_writer](https://github.com/Zncl2222/openpyxl_style_writer)
package, which is built for openpyxl to write styles in write-only
mode more efficiently without duplicating code.
Future Plans:
This project plans to create its own `Style` object, making it no longer
dependent on the mentioned package.
Raw data
{
"_id": null,
"home_page": "https://github.com/Zncl2222/pyfastexcel",
"name": "pyfastexcel",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Zncl2222",
"author_email": "3002shinning@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ac/21/d1606e0fa9125eebd54ef43a0b8d9a8138d06fcdb0b79ac6ca7b54d82ea7/pyfastexcel-0.0.8.tar.gz",
"platform": null,
"description": "# pyfastexcel\n\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Zncl2222/pyfastexcel/go.yml?logo=go)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Zncl2222/pyfastexcel)](https://goreportcard.com/report/github.com/Zncl2222/pyfastexcel)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Zncl2222/pyfastexcel/pre-commit.yml?logo=pre-commit&label=pre-commit)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Zncl2222/pyfastexcel/codeql.yml?logo=github&label=CodeQL)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/03f42030775045b791586dee20288905)](https://app.codacy.com/gh/Zncl2222/pyfastexcel/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)\n[![codecov](https://codecov.io/gh/Zncl2222/pyfastexcel/graph/badge.svg?token=6I03AWUUWL)](https://codecov.io/gh/Zncl2222/pyfastexcel)\n[![Documentation Status](https://readthedocs.org/projects/pyfastexcel/badge/?version=stable)](https://pyfastexcel.readthedocs.io/en/stable/?badge=stable)\n\nThis package enables high-performance Excel writing by integrating with the\nstreaming API from the golang package\n[excelize](https://github.com/qax-os/excelize). Users can leverage this\nfunctionality without the need to write any Go code, as the entire process\ncan be accomplished through Python.\n\n## Features\n\n- Python and Golang Integration: Seamlessly call Golang built shared\nlibraries from Python.\n\n- No Golang Code Required: Users can solely rely on Python for Excel file\ngeneration, eliminating the need for Golang expertise.\n\n## Installation\n\n### Install via pip (Recommended)\n\nYou can easily install the package via pip\n\n```bash\npip install pyfastexcel\n```\n\n### Install manually\n\nIf you prefer to build the package manually, follow these steps:\n\n1. Clone the repository:\n\n ```bash\n git clone https://github.com/Zncl2222/pyfastexcel.git\n ```\n\n2. Go to the project root directory:\n\n ```bash\n cd pyfastexcel\n ```\n\n3. Install the required golang packages:\n\n ```bash\n go mod download\n ```\n\n4. Build the Golang shared library using the Makefile:\n\n ```bash\n make\n ```\n\n5. Install the required python packages:\n\n ```bash\n pip install -r requirements.txt\n ```\n\n or\n\n ```bash\n pipenv install\n ```\n\n6. Import the project and start using it!\n\n## Usage\n\nThe index assignment is now avaliable in `Workbook` and the `FastWriter`.\nHere is the example usage:\n\n```python\nfrom pyfastexcel import Workbook\nfrom pyfastexcel.utils import set_custom_style\n\n# CustomStyle will be integrate to the pyfatexcel in next version\n# Beside, CustomStyle will be re-implement in future to make it no-longer\n# depend on openpyxl_style writer and openpyxl\nfrom openpyxl_style_writer import CustomStyle\n\n\nif __name__ == '__main__':\n # Workbook\n wb = Workbook()\n\n # Set and register CustomStyle\n bold_style = CustomStyle(font_size=15, font_bold=True)\n set_custom_style('bold_style', bold_style)\n\n ws = wb['Sheet1']\n # Write value with default style\n ws['A1'] = 'A1 value'\n # Write value with custom style\n ws['B1'] = ('B1 value', 'bold_style')\n\n # Write value in slice with default style\n ws['A2': 'C2'] = [1, 2, 3]\n # Write value in slice with custom style\n ws['A3': 'C3'] = [(1, 'bold_style'), (2, 'bold_style'), (3, 'bold_style')]\n\n # Write value by row with default style (python index 0 is the index 1 in excel)\n ws[3] = [9, 8, 'go']\n # Write value by row with custom style\n ws[4] = [(9, 'bold_style'), (8, 'bold_style'), ('go', 'bold_style')]\n\n # Send request to golang lib and create excel\n wb.read_lib_and_create_excel()\n\n # File path to save\n file_path = 'pyexample_workbook.xlsx'\n wb.save(file_path)\n\n```\n\nYou can also using the `FastWriter` or `NormalWriter` which was the\nsubclass of `Workbook` to write excel row by row, see the more in documentations [quickstart](https://pyfastexcel.readthedocs.io/en/stable/quickstart/).\n\n## Documentation\n\nThe documentation is hosted on Read the Docs.\n\n- [Development Version](https://pyfastexcel.readthedocs.io/en/latest/)\n\n- [Latest Stable Version](https://pyfastexcel.readthedocs.io/en/stable/)\n\n## Benchmark\n\nThe following result displays the performance comparison between\n`pyfastexcel` and `openpyxl` for writing 50000 rows with 30\ncolumns (Total 1500000 cells). To see more benchmark results, please\nsee the [benchmark](https://pyfastexcel.readthedocs.io/en/stable/benchmark/).\n\n<dev align='center'>\n <img src='./docs/images/50000_30_horizontal_Windows11.png' width=\"80%\" height=\"45%\" >\n</dev>\n\n## How it Works\n\nThe core functionality revolves around encoding Excel cell data and styles,\nor any other Excel properties, into a JSON string within Python. This JSON\npayload is then passed through ctypes to a Golang shared library. In Golang,\nthe JSON is parsed, and using the streaming writer of\n[excelize](https://github.com/qax-os/excelize) to wrtie excel in\nhigh performance.\n\n## Current Limitations & Future Plans\n\n### Problem 1: Dependence on Other Excel Package\n\nLimitations:\n\nThis project currently depends on the `CustomStyle` object of\nthe [openpyxl_style_writer](https://github.com/Zncl2222/openpyxl_style_writer)\npackage, which is built for openpyxl to write styles in write-only\nmode more efficiently without duplicating code.\n\nFuture Plans:\n\nThis project plans to create its own `Style` object, making it no longer\ndependent on the mentioned package.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "High performace excel file generation library.",
"version": "0.0.8",
"project_urls": {
"Homepage": "https://github.com/Zncl2222/pyfastexcel"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e7f2f6a2f60954c9fe484ee4414502df8487db10cd78f8d53a18eed4a4aa8dc2",
"md5": "ecd49978666148ad339da59f1e03df6a",
"sha256": "3748169504e92d090578b23ea331f557e0773a7d11dfbd4a400c857ab28834e3"
},
"downloads": -1,
"filename": "pyfastexcel-0.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ecd49978666148ad339da59f1e03df6a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 6587349,
"upload_time": "2024-06-09T14:08:08",
"upload_time_iso_8601": "2024-06-09T14:08:08.825444Z",
"url": "https://files.pythonhosted.org/packages/e7/f2/f6a2f60954c9fe484ee4414502df8487db10cd78f8d53a18eed4a4aa8dc2/pyfastexcel-0.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ac21d1606e0fa9125eebd54ef43a0b8d9a8138d06fcdb0b79ac6ca7b54d82ea7",
"md5": "6943d061586b3fb66d109b3b35a43312",
"sha256": "0c389f9b6ba9d1897c288ebdc18df404b9d0c50a5a2f249784f7f03ccdf5f7e9"
},
"downloads": -1,
"filename": "pyfastexcel-0.0.8.tar.gz",
"has_sig": false,
"md5_digest": "6943d061586b3fb66d109b3b35a43312",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6549488,
"upload_time": "2024-06-09T14:08:10",
"upload_time_iso_8601": "2024-06-09T14:08:10.641483Z",
"url": "https://files.pythonhosted.org/packages/ac/21/d1606e0fa9125eebd54ef43a0b8d9a8138d06fcdb0b79ac6ca7b54d82ea7/pyfastexcel-0.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-09 14:08:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Zncl2222",
"github_project": "pyfastexcel",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "et-xmlfile",
"specs": [
[
"==",
"1.1.0"
]
]
},
{
"name": "msgspec",
"specs": [
[
"==",
"0.18.6"
]
]
},
{
"name": "openpyxl",
"specs": [
[
"==",
"3.1.2"
]
]
},
{
"name": "openpyxl-style-writer",
"specs": [
[
"==",
"1.1.3"
]
]
}
],
"lcname": "pyfastexcel"
}