Skip to main content

High-performance Excel writer with automatic type detection (pandas, polars, CSV)

Project description

xlsxturbo

High-performance Excel writer with automatic type detection. Written in Rust, usable from Python.

Features

  • Direct DataFrame support for pandas and polars
  • Excel tables - filterable tables with 61 built-in styles (banded rows, autofilter)
  • Auto-fit columns - automatically adjust column widths to fit content
  • Custom column widths - set specific widths per column
  • Custom row heights - set specific heights per row
  • Freeze panes - freeze header row for easier scrolling
  • Multi-sheet workbooks - write multiple DataFrames to one file
  • Constant memory mode - minimize RAM usage for very large files
  • Parallel CSV processing - optional multi-core parsing for large files
  • Automatic type detection from CSV strings and Python objects:
    • Integers and floats → Excel numbers
    • true/false → Excel booleans
    • Dates (2024-01-15, 15/01/2024, etc.) → Excel dates with formatting
    • Datetimes (ISO 8601) → Excel datetimes
    • NaN/Inf → Empty cells (graceful handling)
    • Everything else → Text
  • ~25x faster than pandas + openpyxl
  • Memory efficient - streams data with 1MB buffer
  • Available as both Python library and CLI tool

Installation

pip install xlsxturbo

Or build from source:

pip install maturin
maturin develop --release

Python Usage

DataFrame Export (pandas/polars)

import xlsxturbo
import pandas as pd

# Create a DataFrame
df = pd.DataFrame({
    'name': ['Alice', 'Bob'],
    'age': [30, 25],
    'salary': [50000.50, 60000.75],
    'active': [True, False]
})

# Export to XLSX (preserves types: int, float, bool, date, datetime)
rows, cols = xlsxturbo.df_to_xlsx(df, "output.xlsx")
print(f"Wrote {rows} rows and {cols} columns")

# Works with polars too!
import polars as pl
df_polars = pl.DataFrame({'x': [1, 2, 3], 'y': [4.0, 5.0, 6.0]})
xlsxturbo.df_to_xlsx(df_polars, "polars_output.xlsx", sheet_name="Data")

Excel Tables with Styling

import xlsxturbo
import pandas as pd

df = pd.DataFrame({
    'Product': ['Widget A', 'Widget B', 'Widget C'],
    'Price': [19.99, 29.99, 39.99],
    'Quantity': [100, 75, 50],
})

# Create a styled Excel table with autofilter, banded rows, and auto-fit columns
xlsxturbo.df_to_xlsx(df, "report.xlsx",
    table_style="Medium9",   # Excel's default table style
    autofit=True,            # Fit column widths to content
    freeze_panes=True        # Freeze header row for scrolling
)

# Available styles: Light1-Light21, Medium1-Medium28, Dark1-Dark11
xlsxturbo.df_to_xlsx(df, "dark_table.xlsx", table_style="Dark1", autofit=True)

Custom Column Widths and Row Heights

import xlsxturbo
import pandas as pd

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Department': ['Engineering', 'Marketing', 'Sales'],
    'Salary': [75000, 65000, 55000]
})

# Set specific column widths (column index -> width in characters)
xlsxturbo.df_to_xlsx(df, "report.xlsx", 
    column_widths={0: 20, 1: 25, 2: 15}
)

# Set specific row heights (row index -> height in points)
xlsxturbo.df_to_xlsx(df, "report.xlsx",
    row_heights={0: 25}  # Make header row taller
)

# Combine with other options
xlsxturbo.df_to_xlsx(df, "styled.xlsx",
    table_style="Medium9",
    freeze_panes=True,
    column_widths={0: 20, 1: 30, 2: 15},
    row_heights={0: 22}
)

Multi-Sheet Workbooks

import xlsxturbo
import pandas as pd

# Write multiple DataFrames to separate sheets
df1 = pd.DataFrame({'product': ['A', 'B'], 'sales': [100, 200]})
df2 = pd.DataFrame({'region': ['East', 'West'], 'total': [500, 600]})

xlsxturbo.dfs_to_xlsx([
    (df1, "Products"),
    (df2, "Regions")
], "report.xlsx")

# With styling applied to all sheets
xlsxturbo.dfs_to_xlsx([
    (df1, "Products"),
    (df2, "Regions")
], "styled_report.xlsx", table_style="Medium2", autofit=True, freeze_panes=True)

# With column widths applied to all sheets
xlsxturbo.dfs_to_xlsx([
    (df1, "Products"),
    (df2, "Regions")
], "report.xlsx", column_widths={0: 20, 1: 15})

Constant Memory Mode (Large Files)

For very large files (millions of rows), use constant_memory=True to minimize RAM usage:

import xlsxturbo
import polars as pl

# Generate a large DataFrame
large_df = pl.DataFrame({
    'id': range(1_000_000),
    'value': [i * 1.5 for i in range(1_000_000)]
})

# Use constant_memory mode for large files
xlsxturbo.df_to_xlsx(large_df, "big_file.xlsx", constant_memory=True)

# Also works with dfs_to_xlsx
xlsxturbo.dfs_to_xlsx([
    (large_df, "Data")
], "multi_sheet.xlsx", constant_memory=True)

Note: Constant memory mode disables some features that require random access:

  • table_style (Excel tables)
  • freeze_panes
  • row_heights
  • autofit

Column widths still work in constant memory mode.

CSV Conversion

import xlsxturbo

# Convert CSV to XLSX with automatic type detection
rows, cols = xlsxturbo.csv_to_xlsx("input.csv", "output.xlsx")
print(f"Converted {rows} rows and {cols} columns")

# Custom sheet name
xlsxturbo.csv_to_xlsx("data.csv", "report.xlsx", sheet_name="Sales Data")

# For large files (100K+ rows), use parallel processing
xlsxturbo.csv_to_xlsx("big_data.csv", "output.xlsx", parallel=True)

CLI Usage

xlsxturbo input.csv output.xlsx [--sheet-name "Sheet1"] [-v]

Options

  • -s, --sheet-name: Name of the Excel sheet (default: "Sheet1")
  • -v, --verbose: Show progress information

Example

xlsxturbo sales.csv report.xlsx --sheet-name "Q4 Sales" -v

Performance

Benchmarked on 525,684 rows x 98 columns:

Method Time Speedup
xlsxturbo 28.5s 26.7x
PyExcelerate 107s 7.1x
pandas + xlsxwriter 374s 2.0x
pandas + openpyxl 762s 1.0x
polars.write_excel 1039s 0.7x

Type Detection Examples

CSV Value Excel Type Notes
123 Number Integer
3.14159 Number Float
true / FALSE Boolean Case insensitive
2024-01-15 Date Formatted as date
2024-01-15T10:30:00 DateTime ISO 8601 format
NaN Empty Graceful handling
hello world Text Default

Supported date formats: YYYY-MM-DD, YYYY/MM/DD, DD-MM-YYYY, DD/MM/YYYY, MM-DD-YYYY, MM/DD/YYYY

Building from Source

Requires Rust toolchain and maturin:

# Install maturin
pip install maturin

# Development build
maturin develop

# Release build (optimized)
maturin develop --release

# Build wheel for distribution
maturin build --release

Benchmarking

Run the included benchmark script:

# Default: 100K rows x 50 columns
python benchmark.py

# Custom size
python benchmark.py --rows 500000 --cols 100

License

MIT

Project details


Download files

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

Source Distribution

xlsxturbo-0.4.1.tar.gz (29.5 kB view details)

Uploaded Source

Built Distributions

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

xlsxturbo-0.4.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (866.2 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

xlsxturbo-0.4.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (870.3 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

xlsxturbo-0.4.1-cp38-abi3-win_amd64.whl (886.4 kB view details)

Uploaded CPython 3.8+Windows x86-64

xlsxturbo-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (931.9 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

xlsxturbo-0.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (869.7 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

xlsxturbo-0.4.1-cp38-abi3-macosx_11_0_arm64.whl (843.9 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

xlsxturbo-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl (895.9 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file xlsxturbo-0.4.1.tar.gz.

File metadata

  • Download URL: xlsxturbo-0.4.1.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xlsxturbo-0.4.1.tar.gz
Algorithm Hash digest
SHA256 908fc48568ca3d4ffedd7d823331294ea35973d4f59cada11bc8476e84aa94c1
MD5 ecb6374f0470922837dee1c82f096f1a
BLAKE2b-256 3a28d1e6f4b9c3c9a08d5e9ead286e679fda4d99904dd90ffa51cf6d0d618e7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlsxturbo-0.4.1.tar.gz:

Publisher: release.yml on tstone-1/xlsxturbo

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

File details

Details for the file xlsxturbo-0.4.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xlsxturbo-0.4.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 86e2a8567b4e3a0274a7a3c2fe03f47e2fb6bcd0d4622319a63408f6b58a40a5
MD5 9d9e6437358a58e452b56cba25d48dcd
BLAKE2b-256 3a11913b205b902c32167768a459a1fa6669d1854c8829d101911e1a6e0a2bfb

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlsxturbo-0.4.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on tstone-1/xlsxturbo

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

File details

Details for the file xlsxturbo-0.4.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xlsxturbo-0.4.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7cf2452c9a0e8f69692fb73020e139d9fcf8fd475b79bd5462281c0bfa2014ea
MD5 dd0a83aa2ec1745fbc850b2a8e16ab1c
BLAKE2b-256 5fec9fdeb1893660030573b17fb64b2eb9be803b845dfcf1615017760fd44f82

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlsxturbo-0.4.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on tstone-1/xlsxturbo

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

File details

Details for the file xlsxturbo-0.4.1-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: xlsxturbo-0.4.1-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 886.4 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xlsxturbo-0.4.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6c0678367ce3e36a078688d461fdcd9068456444633b6c5cb071caadceeebf17
MD5 214e850e62060629b6019ecb540879b0
BLAKE2b-256 a0dffca4a704eb80b65ef656d18309ee32f48f531beb1de698a00e0e89794dc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlsxturbo-0.4.1-cp38-abi3-win_amd64.whl:

Publisher: release.yml on tstone-1/xlsxturbo

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

File details

Details for the file xlsxturbo-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xlsxturbo-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 43093688b21c3e1d7dfb750936a205f139f0363dce7a3d7631fb8fc911bbd8fd
MD5 85de83fe93a54c0bc41fe3872f423e2c
BLAKE2b-256 03dea706d03dfea7ebfbb7a261abb5b5f961b58b892bbc1aaf4bfd80f936671e

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlsxturbo-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on tstone-1/xlsxturbo

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

File details

Details for the file xlsxturbo-0.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for xlsxturbo-0.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6b7527cc1ad5d767d99086faf6e7a0156674c878206ecfca8568efab5bd9a0f4
MD5 4041b32e0a339aeb6fae9af2fa18b7c1
BLAKE2b-256 32f810c058795204958d09fb0a6638635ae9588c09cdc7250c60b6ce16e2c608

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlsxturbo-0.4.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on tstone-1/xlsxturbo

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

File details

Details for the file xlsxturbo-0.4.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xlsxturbo-0.4.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2550da3ce7ccdf16ce4b3a1bc75a5c72d5367ee3193f9f1c344bd8683431bad5
MD5 4e5241d33b8978f70a39cde955630c7a
BLAKE2b-256 8dfc8caf57fdb6beb8db93f89400a114c9378c7d3837565d90f446b5326a9bee

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlsxturbo-0.4.1-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on tstone-1/xlsxturbo

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

File details

Details for the file xlsxturbo-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for xlsxturbo-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 160891efe998244d87337123755faa14125379241807e42c2e94fe31c2719a24
MD5 328d698feb9aa2ba6809013f5f9d75c5
BLAKE2b-256 61c0e63c20c171f7cf349974655a83b58fde59a0ecf63c281c9821e1fc4f2066

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlsxturbo-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on tstone-1/xlsxturbo

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page