Skip to main content
Pre-release

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

xlinject

CI

A surgical XML injector for .xlsx files.

xlinject is designed to read and write specific cell values directly inside the XLSX archive while preserving formatting, metadata, and modern Excel dynamic array semantics.

Status: Alpha testing/release - API-first

Release note

0.2.0b2 fixes an Excel compatibility issue in the worksheet XML serializer. Workbooks produced by the previous xml.etree round-trip could still be read by ZIP tools and openpyxl, but some files were rejected by Excel itself after write operations. The serializer path now uses lxml, which preserves the required worksheet markup more safely.

Who this is for

xlinject is useful when you have Excel templates with modern formulas (LET, FILTER, dynamic arrays, custom metadata) and need to inject measured values without changing workbook structure or formatting.

Typical workflow:

  1. Fetch data from an external API.
  2. Build a mapping from A1 cell references to numeric values.
  3. Inject values with xlinject.
  4. Open workbook in Excel with formulas and layout preserved.

Why this project exists

Object-model-based libraries often deserialize and reserialize full workbook structures. During that process, unsupported XML tags/attributes can be dropped. xlinject will instead target specific XML nodes in-place to minimize collateral changes.

Direct write API

from pathlib import Path
from xlinject import inject_cells

report = inject_cells(
	"source.xlsx",
	"output.xlsx",
	sheet_name="Eingabemaske",
	cell_values={
		"B45": 45717.25,
		"C45": "12,34",
		"D45": 15.67,
	},
	guard_cells=["H2"],
)

print(report)

This writes only the listed cells and keeps formula XML intact unless allow_formula_overwrite=True is explicitly set.

Mixed write API

from xlinject import inject_cells_mixed

report = inject_cells_mixed(
	"source.xlsx",
	"output.xlsx",
	sheet_name="Template",
	cell_values={
		"B10": "BK4S1-0008738",
		"B16": 310,
		"B17": 129,
		"B20": "ja",
	},
	guard_cells=["B19", "B25"],
	validate_sheet_rules=True,
)

print(report)

inject_cells_mixed uses the same XML-first strategy as the numeric writer, but can also write string cells as inlineStr while preserving neighboring XML. When validate_sheet_rules=True, direct worksheet validations such as list, textLength, whole, and decimal are checked before the workbook is mutated.

Development setup (uv)

Prerequisites

  • Python 3.11+
  • uv

Quick start

uv sync --dev
uv run pre-commit install

Quality checks

uv run pre-commit run --all-files
uv run ruff check .
uv run mypy .
uv run pytest

License

xlinject is open source under the GNU General Public License v3.0 or later (GPL-3.0-or-later). See LICENSE for the full license text.

Release files for xlinject 0.2.0b2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xlinject 0.2.0b2
File Size Uploaded
xlinject-0.2.0b2.tar.gz 104.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xlinject 0.2.0b2
File Interpreter ABI Platform
xlinject-0.2.0b2-py3-none-any.whl Python 3 none any Details

Total release size: 145.9 kB

Release files / xlinject-0.2.0b2.tar.gz

Download URL xlinject-0.2.0b2.tar.gz
Size 104.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5420e12203e833980fc4ca3ad9aef0565d35d5adf1ebd75dfbe8889b5407f56d
BLAKE2b-256 checksum
How to use checksums
86b8c15dc5854445f5f88126f87671b712ca8d962486db28cf15f88311c2e61a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.

Transparency log

Release files / xlinject-0.2.0b2-py3-none-any.whl

Download URL xlinject-0.2.0b2-py3-none-any.whl
Size 41.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e305058f516988d434e3be0422173d869c654ee8f82e969dacacdfd23bec73d1
BLAKE2b-256 checksum
How to use checksums
b517948ea10d9e50a685ae351ae5e5e334512c75a7e6245ff7d4264dd4499314
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 1, 2026.

Transparency log
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