Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pyfastexcel

GitHub Actions Workflow Status Go Report Card GitHub Actions Workflow Status GitHub Actions Workflow Status Codacy Badge codecov Documentation Status

This package enables high-performance Excel writing by integrating with the streaming API from the golang package 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

pip install pyfastexcel

Install manually

If you prefer to build the package manually, follow these steps:

  1. Clone the repository:

    git clone https://github.com/Zncl2222/pyfastexcel.git
    
  2. Go to the project root directory:

    cd pyfastexcel
    
  3. Install the required golang packages:

    go mod download
    
  4. Build the Golang shared library using the Makefile:

    make
    
  5. Install the required python packages:

    pip install -r requirements.txt
    

    or

    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:

from pyfastexcel import Workbook
from pyfastexcel.utils import set_custom_style

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 documentation.

Explore additional examples in the FullExamples.

Documentation

The documentation is hosted on Read the Docs.

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.

How it Works

Python keeps the existing workbook and (value, style_name) API. With the bundled ABI-v2 library it sends JSON metadata plus MessagePack row frames over a length-aware ctypes boundary; Go decodes one row at a time and writes it with excelize. Older native libraries are detected automatically and continue to use the complete JSON/base64 protocol. The generated XLSX is returned as raw bytes, or written through the compatible direct-file path when save(path) is used.

Row decoding runs concurrently with excelize's row serialization, workbooks with multiple stream sheets are written with one worker per sheet, and the hot Python paths (row_append, the wire encoder) use cached style resolution with tight per-row loops. Two opt-in speedups are available on top of that: append_row/append_rows write whole rows per call (2-3x faster than a per-cell loop, styles may vary per column), and set_zip_compression_level(6) swaps the final DEFLATE stage for klauspost/compress (about 3x faster compression for roughly 20% larger, fully standard files). Without opt-ins the output archives stay byte-for-byte identical to previous releases.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyfastexcel-0.2.0rc0-py3-none-win_amd64.whl (4.7 MB view details)

Uploaded Python 3Windows x86-64

pyfastexcel-0.2.0rc0-py3-none-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file pyfastexcel-0.2.0rc0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for pyfastexcel-0.2.0rc0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 0622bb645ec8dce441f0f1493e817e8f5f5c16f03820a7ae3e3e970b083e0f7c
MD5 0497c3051ed353a93d5b87e005f6d1ac
BLAKE2b-256 1ec3eea685f7aa633f35fb03d84d18d8245d515701131882b07359238be04910

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfastexcel-0.2.0rc0-py3-none-win_amd64.whl:

Publisher: pypi.yml on Zncl2222/pyfastexcel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfastexcel-0.2.0rc0-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyfastexcel-0.2.0rc0-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 50d6df5434fa8925058567ae4db93920f6c3ad20da054313a2d8a0b9206b5ec7
MD5 600c83ed01e11ebe5b4be835c7c32cec
BLAKE2b-256 a55a63d8441ea18eb560c848557472d42de3bc08ac703cf22ecdc4000a147126

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfastexcel-0.2.0rc0-py3-none-manylinux2014_x86_64.whl:

Publisher: pypi.yml on Zncl2222/pyfastexcel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfastexcel-0.2.0rc0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyfastexcel-0.2.0rc0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8089fb37dd8441d19e1116cec1c899da54c552dc0d9b732a8657f3cb364daa6d
MD5 49baeed254198c6cda7c28876ab32e29
BLAKE2b-256 947934071ee2c6eefdf54ff29a823a2f278064169ebc127fa7b6c2bfe3b40c68

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfastexcel-0.2.0rc0-py3-none-macosx_11_0_arm64.whl:

Publisher: pypi.yml on Zncl2222/pyfastexcel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0rc0 This release

3 files

0.1.9

3 files

0.1.8

3 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page