Skip to content

Introduction

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.

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 to wrtie excel in high performance.

Dependency

The dependency for python and golang

python:

msgspec (for faster json encoding)
pydantic v2

golang:

excelize (Core functionality)
marshmallow (for faster json decoding)

Installation

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.

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.