A surgical XML injector for .xlsx files. Reads and writes specific cell values directly into the archive without altering formatting, metadata, or breaking modern dynamic array formulas.
Project description
xlinject
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
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:
- Fetch data from an external API.
- Build a mapping from
A1cell references to numeric values. - Inject values with
xlinject. - 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xlinject-0.2.0b1.tar.gz.
File metadata
- Download URL: xlinject-0.2.0b1.tar.gz
- Upload date:
- Size: 95.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d590d1cc1b54b46d1f50c7aacf0ae2edaf81161f590ba9822be18a36f8110669
|
|
| MD5 |
23c65aee15685061588c127ffb409c6a
|
|
| BLAKE2b-256 |
c56cfd7b97ffb70a7d4750d36ae6a69702f5eaf43f6ea375201c33a63d626b62
|
Provenance
The following attestation bundles were made for xlinject-0.2.0b1.tar.gz:
Publisher:
publish-pypi.yml on KyleDerZweite/xlinject
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xlinject-0.2.0b1.tar.gz -
Subject digest:
d590d1cc1b54b46d1f50c7aacf0ae2edaf81161f590ba9822be18a36f8110669 - Sigstore transparency entry: 1203567948
- Sigstore integration time:
-
Permalink:
KyleDerZweite/xlinject@10c0b41d0975527416d9c5e71aa707df904edc85 -
Branch / Tag:
refs/tags/v0.2.0b1 - Owner: https://github.com/KyleDerZweite
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@10c0b41d0975527416d9c5e71aa707df904edc85 -
Trigger Event:
release
-
Statement type:
File details
Details for the file xlinject-0.2.0b1-py3-none-any.whl.
File metadata
- Download URL: xlinject-0.2.0b1-py3-none-any.whl
- Upload date:
- Size: 41.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3ed9f5a4d786b829bf5ad4e74d8a6f57016c76f6bceb712685fd967854b2621
|
|
| MD5 |
4cc8cd23f82df2da93ae81e97078d6a6
|
|
| BLAKE2b-256 |
24f443869c861354f3d4ff36532d54b794a487c428a74a48bbc67e6d188fefa2
|
Provenance
The following attestation bundles were made for xlinject-0.2.0b1-py3-none-any.whl:
Publisher:
publish-pypi.yml on KyleDerZweite/xlinject
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xlinject-0.2.0b1-py3-none-any.whl -
Subject digest:
d3ed9f5a4d786b829bf5ad4e74d8a6f57016c76f6bceb712685fd967854b2621 - Sigstore transparency entry: 1203567950
- Sigstore integration time:
-
Permalink:
KyleDerZweite/xlinject@10c0b41d0975527416d9c5e71aa707df904edc85 -
Branch / Tag:
refs/tags/v0.2.0b1 - Owner: https://github.com/KyleDerZweite
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@10c0b41d0975527416d9c5e71aa707df904edc85 -
Trigger Event:
release
-
Statement type: