bankstatementparser-writer-xlsx
Excel (.xlsx) writer for bankstatementparser-parsed bank statements: a bold header, one row per transaction, auto-sized columns and an optional summary sheet.
Contents
Getting started
- Install: PyPI, source
- Requirements: toolchain floor, platforms
- Quick Start: parse a statement, write a workbook
The bankstatementparser-writer-xlsx ecosystem
- The bankstatementparser-writer-xlsx ecosystem: the core library, the loaders and other writers
Library reference
- Capabilities at a glance: the current surface by theme
- Ecosystem comparison: short matrix; full table at
docs/COMPARISON.md - Benchmarks: headline numbers; full table at
docs/BENCHMARKS.md - Features: input shapes, value coercion, errors, the summary sheet
- Configuration: core options
- Examples: runnable example index
Operational
- When not to use bankstatementparser-writer-xlsx: limitations
- Development: make targets, fuzzing, CI
- Security: guarantees and compliance
- Documentation: all reference docs
- Stability guarantees: SemVer axis, output stability, minimum toolchain discipline
- License
Install
As a Python library
pip install bankstatementparser-writer-xlsx
That installs the writer and pulls in bankstatementparser >= 0.0.35, openpyxl and pandas automatically.
| Channel | Command | Notes |
|---|---|---|
| PyPI | pip install bankstatementparser-writer-xlsx |
Pulls in bankstatementparser, openpyxl 3.1 or later on 3.x, and pandas 2.0 or later |
| Source | git clone https://github.com/sebastienrousseau/bankstatementparser-writer-xlsx && cd bankstatementparser-writer-xlsx && poetry install |
For development |
Verify the installation:
python -c "import bankstatementparser_writer_xlsx as w; print(w.__version__)"
# -> 0.0.37
Requirements
- Python 3.10 or later. CI tests CPython 3.10, 3.11, 3.12, 3.13 and 3.14 on Linux, macOS and Windows;
docs/POLICIES.mdsays when the floor moves. bankstatementparser0.0.35 or later, whose parsers produce theDataFrameandTransactionobjects the writer takes.openpyxl3.1 or later on 3.x, which writes the workbook, andpandas2.0 or later.- No network access, native extensions or system packages of its own.
Quick Start
from bankstatementparser import CsvStatementParser
from bankstatementparser_writer_xlsx import write_xlsx
parser = CsvStatementParser("statement.csv")
df = parser.parse() # a pandas DataFrame
write_xlsx(df, "statement.xlsx") # one polished workbook
That's an Excel workbook ready for your accountant. Add a summary sheet in one extra argument:
from bankstatementparser import CsvStatementParser
from bankstatementparser_writer_xlsx import write_xlsx
parser = CsvStatementParser("statement.csv")
df = parser.parse()
write_xlsx(df, "statement.xlsx", summary=parser.get_summary())
Latest release: v0.0.37, a single write_xlsx(data, path, ...) function.
The bankstatementparser-writer-xlsx ecosystem
bankstatementparser-writer-xlsx is one of the output writers of the bankstatementparser suite, whose packages ship one version together. The full table is in The suite.
| Component | Purpose | Use case |
|---|---|---|
bankstatementparser |
The parser core: CAMT, pain.001, CSV, OFX, QFX, MT940, MT942, BAI2 and PDF statements, and the Transaction model |
Parsing statements from Python or the CLI |
bankstatementparser-writer-xlsx |
This writer: parsed records to an .xlsx workbook |
Handing statements to people who work in Excel |
| Other writers | QIF, OFX and SWIFT MT940 / MT942 | Feeding accounting software and banks |
| Loaders and transport | BAI2, MT942, CFONB 120, CAMT.054, SEPA and BACS loaders; EBICS retrieval | Formats beyond the core, and fetching statements |
bankstatementparser-mcp, bankstatementparser-lsp |
Agent tools and editor diagnostics over the core | AI agents and MT940 editing |
flowchart LR
A["bankstatementparser parser"] -->|DataFrame / list of Transaction| B["write_xlsx"]
C["list of dict"] --> B
B --> D["statement.xlsx: Transactions sheet"]
B -->|summary=| E["Summary sheet"]
Capabilities at a glance
| Area | Capability | Status |
|---|---|---|
| Input | DataFrame, list[Transaction], list[dict] |
Shipped |
| Values | Decimal as numbers, native date cells, blanks for None / NaN / missing keys |
Shipped |
| Layout | Bold header, columns auto-sized and capped at 60 characters, custom sheet name | Shipped |
| Summary | summary= mapping written to a Summary sheet |
Shipped |
| Core integration | Registered as the xlsx entry point in bankstatementparser.writers |
Shipped |
| Number formats, frozen header, auto-filter | Formatting polish | Planned (roadmap) |
Ecosystem comparison
The usual alternative is pandas' own DataFrame.to_excel. Every cell comes from writing the same frame with both and reading the workbooks back with openpyxl.
| Project | Input shapes | Decimal amounts |
Column widths |
|---|---|---|---|
| bankstatementparser-writer-xlsx | DataFrame, Transaction, dict |
Number cells | Auto-sized, capped |
pandas.DataFrame.to_excel (2.3.3) |
DataFrame |
Text cells | Default |
See docs/COMPARISON.md for the evidence and complete matrix.
Benchmarks
benches/bench_write_xlsx.py times write_xlsx and measures its peak memory, which decides whether an export survives a container limit: the whole workbook is built in memory before anything reaches disk. Time per row is flat from 100 to 50,000 rows, and peak memory runs at up to 65x the size of the file written.
| Scenario | Result | Environment |
|---|---|---|
| 10,000 rows (445 KiB written) | 2,957 ms, 29,021 KiB peak | Apple M1 Pro, macOS 27.2.1, CPython 3.12.16 |
| 50,000 rows (2,213 KiB written) | 15,156 ms, 141,630 KiB peak | Apple M1 Pro, macOS 27.2.1, CPython 3.12.16 |
1,000 rows, list[dict] vs DataFrame |
283.9 ms vs 289.8 ms | Apple M1 Pro, macOS 27.2.1, CPython 3.12.16 |
See docs/BENCHMARKS.md for methodology and full results.
Features
Input shapes
write_xlsx(data, path, *, sheet_name="Transactions", summary=None)
accepts three input shapes and normalises each to a flat table:
| Input | Column order |
|---|---|
pandas.DataFrame (from a parser's .parse()) |
the DataFrame's own column order |
list[bankstatementparser.Transaction] |
the stable Transaction field order |
list[dict] |
the union of keys, in first-seen order |
A header row (bold) is written to the sheet_name sheet, followed by
one row per record. Columns are auto-sized to their widest cell, capped
at 60 characters so wide descriptions don't run off-screen (the cell
content itself is never truncated; only the displayed column width).
Empty input is accepted: an empty list writes an empty sheet (no
header), while an empty DataFrame that still carries column labels
writes a header-only sheet.
Value coercion
Spreadsheet cells can't hold arbitrary Python objects, so the writer coerces the rich types the parser emits:
| Python type | Written as |
|---|---|
decimal.Decimal |
float (Excel has no decimal type; floats aggregate natively) |
datetime.date / datetime.datetime |
native Excel date cell (unchanged) |
str, int, float, bool, None |
unchanged |
None / float('nan') (e.g. a missing DataFrame cell) |
blank cell |
| anything else | str(value) |
bool is preserved as a true/false cell (it is not coerced to 0/1),
and a missing list[dict] key writes a blank cell in the same way a
None value does.
Every string (values, column names and the summary) is written as a
text cell holding exactly the original text: one that starts with =
is never stored as a formula, so a crafted transaction description
cannot become a live formula in the workbook (CWE-1236).
Errors
write_xlsx validates its data argument and fails fast with a precise
exception rather than writing a malformed workbook:
| Condition | Raised |
|---|---|
data is neither a DataFrame nor a list/tuple (e.g. a str or int) |
TypeError |
data is a non-empty sequence whose items are neither dict records nor Transaction objects (e.g. [42]) |
ValueError |
A value, a column name or the summary holds a control character an .xlsx cannot store (C0 characters other than tab, newline and carriage return) |
ValueError |
from bankstatementparser_writer_xlsx import write_xlsx
try:
write_xlsx("not-a-table", "out.xlsx") # a bare str is not a table
except TypeError as exc:
print(f"rejected: {exc}")
try:
write_xlsx([42], "out.xlsx") # 42 is not a dict/Transaction
except ValueError as exc:
print(f"rejected: {exc}")
The summary sheet
If you pass summary= a mapping (for example a parser's
get_summary() result), the writer adds a second sheet titled
Summary with a bold Key / Value header and one row per item:
from decimal import Decimal
from bankstatementparser_writer_xlsx import write_xlsx
transactions = [
{"date": "2026-06-01", "description": "Salary", "amount": Decimal("3000.00")},
{"date": "2026-06-03", "description": "Coffee Shop", "amount": Decimal("-4.20")},
]
write_xlsx(
transactions,
"out.xlsx",
summary={
"account_id": "DE89370400440532013000",
"transaction_count": 128,
"total_amount": Decimal("12045.67"),
"currency": "EUR",
},
)
Configuration
write_xlsx has two options, both keyword-only: sheet_name (the title of the transactions sheet, "Transactions" by default) and summary (a mapping for the optional Summary sheet). There is no configuration file and no environment variable. Installing the package registers write_xlsx under the xlsx name in the bankstatementparser.writers entry-point group, which is how the core discovers it.
Examples
Six runnable examples live in examples/ and are exercised in CI on every commit. Together they cover every supported input shape, option, coercion rule, and error path of write_xlsx:
| Example | Demonstrates |
|---|---|
01_write_dataframe.py |
A pandas DataFrame to a single sheet |
02_write_transactions.py |
A list of Transaction objects in stable field order |
03_write_dicts.py |
A list of plain dict records (union of keys) |
04_write_with_summary.py |
A DataFrame plus a second Summary sheet via summary= |
05_custom_sheet_name.py |
Renaming the transactions sheet with sheet_name= |
06_value_coercion_and_errors.py |
Decimal/date coercion, None/NaN/missing keys as blank cells, the 60-character column-width cap, and the TypeError/ValueError error paths |
Each writes to a temporary file, reads it back with openpyxl and leaves nothing behind:
python examples/04_write_with_summary.py
When not to use bankstatementparser-writer-xlsx
- You need a custom sheet layout. The single-sheet (+ optional Summary) structure is intentionally simple. Compose your own
openpyxlworkbook if you need pivot-ready, multi-sheet layouts. - You need
.xls(legacy binary).openpyxlwrites.xlsxonly; convert downstream if you must. - You need encrypted or signed output. Out of scope; encrypt or sign the produced
.xlsxdownstream with a tool likemsoffcrypto-tool. - You want to read Excel. This package is a writer.
- You export far more rows than memory allows. The whole workbook is built in memory first (see Benchmarks); streaming writes are on the roadmap.
Development
git clone https://github.com/sebastienrousseau/bankstatementparser-writer-xlsx.git
cd bankstatementparser-writer-xlsx
poetry install
make check
make check runs the local gates: ruff and black, mypy --strict, the complexity baseline (scripts/check_complexity.py), pytest with a 100% line + branch coverage floor, interrogate at 100% docstring coverage, and the examples. Other targets: make fuzz (Atheris, 60 s, Linux x86_64 with Python 3.12+), make docs (the MkDocs manual, --strict) and make demo (re-renders the GIF above with VHS from .github/demo.tape). CI adds the OS by Python matrix, the fuzz run, CodeQL, pip-audit on the locked requirements and the Docs Lint gates. Documentation and example regression tests (tests/test_docs_accuracy.py, tests/test_regression_docs.py, tests/test_regression_examples.py) execute every documented snippet and every examples/*.py script. CONTRIBUTING.md covers branches and commit signing.
Security
- Parsed data only. The writer consumes already-parsed records, not raw statement files; the PDF / CSV / XML parsing surface lives upstream in the
bankstatementparsercore. - No formula injection. Every string is written as a text cell, never a formula, so bank free text starting with
=stays text (CWE-1236);tests/test_formula_injection.pyreads the workbooks back to check it. - Writes only the path you give it.
write_xlsxcreates or overwrites the one.xlsxatpath; validate that path before calling it. No network, no code execution. - Fuzzing.
fuzz/fuzz_write_xlsx.pydriveswrite_xlsxwith Atheris in CI over fuzzed records, summaries and sheet names, and fails on any exception other thanTypeError/ValueErrorand on a workbook that does not reopen with one row per record. - Supply chain. Dependencies are locked in
poetry.lock, CI installs hash-pinned exports of it, andpip-auditand CodeQL run on every change. Releases publish to PyPI through OIDC trusted publishing and carry cosign signatures, SLSA provenance and SBOMs; every workflow action is pinned by commit SHA except the SLSA generator, which must be referenced by tag.
Report vulnerabilities according to SECURITY.md.
Documentation
- User manual: sebastienrousseau.com/bankstatementparser-writer-xlsx, built from
docs/with MkDocs - API reference: the manual's API page, generated from the docstrings
- Developer docs:
CONTRIBUTING.md,ARCHITECTURE.md,RELEASING.md - The suite:
docs/suite.md, with everybankstatementparserpackage - History:
ROADMAP.md,CHANGELOG.md - openpyxl: openpyxl.readthedocs.io
Stability guarantees
- Versioning. Releases stay on the
0.0.xline and step by exactly0.0.1, in lockstep with the rest of thebankstatementparsersuite. Under SemVer a0.0.xrelease may break anything; this project names each break in the CHANGELOG instead. - The breaking axis is the workbook: the sheets written, the column order for each input shape, how each value is coerced, and which inputs raise. Changing any of them for data that wrote before is a breaking change and is called out in the CHANGELOG, even when no Python signature moves.
- Output stability. The writer is deterministic in its cells: the same data gives the same sheets, headers and values in the same order.
- Python API.
write_xlsxand itssheet_nameandsummarykeywords keep their names; names starting with_are internal. - Minimum toolchain. Python 3.10 is the floor; it moves only in a release, for the whole suite at once, with the reason in the CHANGELOG (
docs/POLICIES.md).
License
Dual-licensed under Apache License, Version 2.0 or MIT, at your option (SPDX-License-Identifier: Apache-2.0 OR MIT). Built on openpyxl and the core bankstatementparser library. Any contribution submitted for inclusion in the work shall be dual-licensed as above, without additional terms or conditions.
Metadata
Release files for bankstatementparser-writer-xlsx 0.0.37
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bankstatementparser_writer_xlsx-0.0.37.tar.gz | 24.0 kB | With provenance | Details for bankstatementparser_writer_xlsx-0.0.37.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bankstatementparser_writer_xlsx-0.0.37-py3-none-any.whl | Python 3 | none | any | Details for bankstatementparser_writer_xlsx-0.0.37-py3-none-any.whl |
Total release size: 43.3 kB
Release files / bankstatementparser_writer_xlsx-0.0.37.tar.gz
| Download URL | bankstatementparser_writer_xlsx-0.0.37.tar.gz |
|---|---|
| Size | 24.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9b51c3983dd87c8795a0546cbac8e2bcb9743886bbd6cf5a045bbc6937e2b78
|
|
BLAKE2b-256 checksum How to use checksums |
58751107c2b9c333442dfee3fa837da05fb5c2f344048764b10d6478c408d30f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 29, 2026.
Transparency logRelease files / bankstatementparser_writer_xlsx-0.0.37-py3-none-any.whl
| Download URL | bankstatementparser_writer_xlsx-0.0.37-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eded1a536bcb4afbc4dead3f1eef1245c2b504a106c891275f24a2f7a3ec18e0
|
|
BLAKE2b-256 checksum How to use checksums |
be9b87879dff5bed87a59bf30dd9d3250cb598ba2211023d0426f3601474edcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 29, 2026.
Transparency logSecurity for bankstatementparser-writer-xlsx 0.0.37
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for bankstatementparser_writer_xlsx-0.0.37.tar.gz
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 Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.