pyfastexcel


Namepyfastexcel JSON
Version 0.1.8 PyPI version JSON
download
home_pagehttps://github.com/Zncl2222/pyfastexcel
SummaryHigh performace excel file generation library.
upload_time2024-12-01 02:07:59
maintainerNone
docs_urlNone
authorZncl2222
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements annotated-types et-xmlfile eval-type-backport msgspec openpyxl openpyxl-style-writer pydantic pydantic-core typing-extensions
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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!

## Requirements

| Operating System | Version                         |
| ---------------- | ------------------------------- |
| **Linux**        | Ubuntu 18.04 or higher          |
| **macOS**        | macOS 13 (x86-64)               |
| **Windows**      | Windows 10 or higher            |


### Python Versions

- **Python 3.8 or higher**

For earlier versions of Python or other operating systems, compatibility is not guaranteed.

## Usage

The index assignment is now avaliable in `Workbook` and the `StreamWriter`.
Here is the example usage:

```python
from pyfastexcel import Workbook
from pyfastexcel.utils import set_custom_style

# CustomStyle will be re-implement in future to make it no-longer
# depend on openpyxl_style writer and openpyxl
from pyfastexcel 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)

```

For row-by-row Excel writing, consider using `StreamWriter`, a
subclass of Workbook. This class is optimized for streaming large datasets.
Learn more in the [StreamWriter](https://pyfastexcel.readthedocs.io/en/stable/writer/) documentation.

Explore additional examples in the [FullExamples](https://github.com/Zncl2222/pyfastexcel/tree/main/examples).

## 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.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Zncl2222",
    "author_email": "3002shinning@gmail.com",
    "download_url": null,
    "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## Requirements\n\n| Operating System | Version                         |\n| ---------------- | ------------------------------- |\n| **Linux**        | Ubuntu 18.04 or higher          |\n| **macOS**        | macOS 13 (x86-64)               |\n| **Windows**      | Windows 10 or higher            |\n\n\n### Python Versions\n\n- **Python 3.8 or higher**\n\nFor earlier versions of Python or other operating systems, compatibility is not guaranteed.\n\n## Usage\n\nThe index assignment is now avaliable in `Workbook` and the `StreamWriter`.\nHere is the example usage:\n\n```python\nfrom pyfastexcel import Workbook\nfrom pyfastexcel.utils import set_custom_style\n\n# CustomStyle will be re-implement in future to make it no-longer\n# depend on openpyxl_style writer and openpyxl\nfrom pyfastexcel 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\nFor row-by-row Excel writing, consider using `StreamWriter`, a\nsubclass of Workbook. This class is optimized for streaming large datasets.\nLearn more in the [StreamWriter](https://pyfastexcel.readthedocs.io/en/stable/writer/) documentation.\n\nExplore additional examples in the [FullExamples](https://github.com/Zncl2222/pyfastexcel/tree/main/examples).\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.1.8",
    "project_urls": {
        "Homepage": "https://github.com/Zncl2222/pyfastexcel"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d0fe6c4fc12aee0b4e57da59fa9c66fba9a91761aca06fc643123f0e017e401",
                "md5": "a687e7241774a648cc7ff3ec0d7946af",
                "sha256": "5b6cd0d8e44ef143c111693b2cc36e32ac01a816850cb0925feb0b064ddf785d"
            },
            "downloads": -1,
            "filename": "pyfastexcel-0.1.8-py3-none-macosx_10_9_x86_64.whl",
            "has_sig": false,
            "md5_digest": "a687e7241774a648cc7ff3ec0d7946af",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 2351983,
            "upload_time": "2024-12-01T02:07:59",
            "upload_time_iso_8601": "2024-12-01T02:07:59.656439Z",
            "url": "https://files.pythonhosted.org/packages/7d/0f/e6c4fc12aee0b4e57da59fa9c66fba9a91761aca06fc643123f0e017e401/pyfastexcel-0.1.8-py3-none-macosx_10_9_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bfa88db94aebedcae7c0259ff84ae0ea43c3a965360e4e9e05045534f5cb8765",
                "md5": "2f3c8b60b9f415fa883eb77b9ebb8132",
                "sha256": "2cef2090c4bba08366761a55f3fe35b15e65f5e9693e651c83093666fb2b072b"
            },
            "downloads": -1,
            "filename": "pyfastexcel-0.1.8-py3-none-manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "2f3c8b60b9f415fa883eb77b9ebb8132",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 3957724,
            "upload_time": "2024-12-01T02:08:07",
            "upload_time_iso_8601": "2024-12-01T02:08:07.581190Z",
            "url": "https://files.pythonhosted.org/packages/bf/a8/8db94aebedcae7c0259ff84ae0ea43c3a965360e4e9e05045534f5cb8765/pyfastexcel-0.1.8-py3-none-manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac8a133e6d492bd4c268231b90a6e52a8f88f71563a04abddeffa1ec0cea48b9",
                "md5": "3e2a04c64f21963e2bb7c62518873a18",
                "sha256": "6bdae0b0be9fa137abb11d4fa63e9523afffdecbe94900f35c826953a24310e8"
            },
            "downloads": -1,
            "filename": "pyfastexcel-0.1.8-py3-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "3e2a04c64f21963e2bb7c62518873a18",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 3867070,
            "upload_time": "2024-12-01T02:08:12",
            "upload_time_iso_8601": "2024-12-01T02:08:12.180376Z",
            "url": "https://files.pythonhosted.org/packages/ac/8a/133e6d492bd4c268231b90a6e52a8f88f71563a04abddeffa1ec0cea48b9/pyfastexcel-0.1.8-py3-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-01 02:07:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Zncl2222",
    "github_project": "pyfastexcel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "annotated-types",
            "specs": []
        },
        {
            "name": "et-xmlfile",
            "specs": []
        },
        {
            "name": "eval-type-backport",
            "specs": []
        },
        {
            "name": "msgspec",
            "specs": []
        },
        {
            "name": "openpyxl",
            "specs": []
        },
        {
            "name": "openpyxl-style-writer",
            "specs": []
        },
        {
            "name": "pydantic",
            "specs": []
        },
        {
            "name": "pydantic-core",
            "specs": []
        },
        {
            "name": "typing-extensions",
            "specs": []
        }
    ],
    "lcname": "pyfastexcel"
}
        
Elapsed time: 1.05326s