Metadata-Version: 2.4
Name: fillxl
Version: 0.2.0
Summary: Fill Excel templates with data from Python.
Project-URL: Homepage, https://github.com/hirolau/fillxl
Project-URL: Source, https://github.com/hirolau/fillxl
Project-URL: Issues, https://github.com/hirolau/fillxl/issues
Author-email: hirolau <hirolau@users.noreply.github.com>
License: MIT License
        
        Copyright (c) 2026 hirolau
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: automation,excel,fillxl,templates
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Office/Business :: Financial :: Spreadsheet
Requires-Python: >=3.11
Requires-Dist: attrs>=23.0
Requires-Dist: openpyxl>=3.1.5
Provides-Extra: all
Requires-Dist: duckdb>=0.9; extra == 'all'
Requires-Dist: pandas>=2.0; extra == 'all'
Requires-Dist: polars>=0.20; extra == 'all'
Requires-Dist: pywin32>=306; (sys_platform == 'win32') and extra == 'all'
Provides-Extra: dev
Requires-Dist: check-wheel-contents>=0.6; extra == 'dev'
Requires-Dist: coverage>=7; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: nox>=2023.12; extra == 'dev'
Requires-Dist: pandas-stubs>=2; extra == 'dev'
Requires-Dist: pyrefly>=1.0; extra == 'dev'
Requires-Dist: pytest-cov>=4; extra == 'dev'
Requires-Dist: pytest-gremlins>=1.9.0; extra == 'dev'
Requires-Dist: pytest-spec>=6.1.0; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff>=0.1; extra == 'dev'
Requires-Dist: twine>=6; extra == 'dev'
Requires-Dist: xlwings>=0.30; extra == 'dev'
Provides-Extra: duckdb
Requires-Dist: duckdb>=0.9; extra == 'duckdb'
Provides-Extra: pandas
Requires-Dist: pandas>=2.0; extra == 'pandas'
Provides-Extra: polars
Requires-Dist: polars>=0.20; extra == 'polars'
Provides-Extra: test
Requires-Dist: duckdb>=1.5.4; extra == 'test'
Requires-Dist: hypothesis>=6.156.3; extra == 'test'
Requires-Dist: pandas>=3.0.3; extra == 'test'
Requires-Dist: polars>=1.42.1; extra == 'test'
Provides-Extra: win32com
Requires-Dist: pywin32>=306; (sys_platform == 'win32') and extra == 'win32com'
Description-Content-Type: text/markdown

# fillxl

[![PyPI version](https://img.shields.io/pypi/v/fillxl.svg)](https://pypi.org/project/fillxl/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)](pyproject.toml)
[![CI](https://github.com/hirolau/fillxl/actions/workflows/ci.yml/badge.svg)](https://github.com/hirolau/fillxl/actions/workflows/ci.yml)

**Fill Excel templates with data from Python.**

Designed around named cells and Excel tables — no more fragile cell references like A1 or B3. Charts, formulas, formatting, and conditional formatting are preserved and updated automatically.

Fill tables using list, pandas, polars or duckdb!

```python
from fillxl import fill
import pandas as pd

fill(
    template="report_template.xlsx",
    output="q4_report.xlsx",
    tables={
        "Products": [
            {"Name": "Widget", "Price": 4.99, "Sold": 150},
            {"Name": "Gadget", "Price": 9.99, "Sold": 85},
        ],
        "Sales": pd.read_csv('sales_data.csv'),
    },
    values={
        "ReportTitle": "Q4 2024 Sales",
        "PreparedBy": "Alice",
    },
)
```

---

## Installation

```bash
pip install fillxl
```

Optional extras:

```bash
pip install fillxl[pandas]   # pandas support
pip install fillxl[all]      # pandas + polars + duckdb
```

---

## Quick Start

1. In Excel, create **named cells** (Name Manager) for single values and **Excel Tables** (`Ctrl + T`) for tabular data.  
2. Fill the template with the code above.

Tables are automatically resized, charts updated, and all formatting preserved.

**Backend (optional)**

```python
fill(..., engine="openpyxl")   # default, cross-platform
fill(..., engine="win32com")   # Windows + Excel installed (maximum fidelity)
```

---

## Visual Example

**Before filling:**

![Before fill](docs/screenshots/before_fill.png)

**After filling:**

![After fill](docs/screenshots/after_fill.png)

---

## Main Features

- Populate named cells and Excel tables
- Automatic table resizing + chart range updates
- Conditional formatting and pivot table refresh
- Two backends: `openpyxl` (default) and `win32com` (Windows + Excel)

---

## API

### `fill()`

```python
fill(
    template: str | Path,
    output: str | Path,
    values: dict[str, Any] | None = None,
    tables: dict[str, list[dict] | DataFrame | ...] | None = None,
    *,
    engine: str = "auto",      # "openpyxl", "win32com"
    config: FillXLConfig | None = None
) -> Path
```

See the full documentation for `FillXLConfig` options.

---

## Supported Data Sources

- `list[dict]`
- `dict[str, list]`
- `pandas.DataFrame`
- `polars.DataFrame`
- `duckdb.DuckDBPyRelation`

---

## Backends

| Engine     | Cross-platform | Requires Excel | Best for                     |
|------------|----------------|----------------|------------------------------|
| `openpyxl` | Yes            | No             | Most use cases, Linux/macOS  |
| `win32com` | Windows only   | Yes            | Modern charts, full fidelity |

---

## Performance

Benchmark: **5,000 rows × 20 columns** (list[dict] data).

| Method                    | Engine     | Time (mean ± std) |
|---------------------------|------------|-------------------|
| `fillxl`                  | openpyxl   | 2.26s ± 0.03s     |
| `fillxl`                  | win32com   | 2.80s ± 0.03s     |
| `pandas.to_excel`         | openpyxl   | 3.01s ± 0.09s     |

---

## Known Limitations

- `openpyxl` does not support dynamic arrays, `.xlsm`, or `.xlsb` files and drops some modern chart types.
- `win32com` requires Windows + Excel.
- Timezone-aware datetimes are converted to naive.

---

## Development

```bash
git clone https://github.com/hirolau/fillxl.git
cd fillxl
uv sync --all-extras
uv run pytest
```

**Supported:** Python 3.11–3.14, Windows/Linux (macOS best-effort).  
**License:** [MIT](LICENSE)
