Fill empty Excel cells inside a selected range, with optional vertical merge support.
Project description
excel-fill-na
excel-fill-na is a small pip-installable library with an fna CLI for filling empty Excel cells inside a selected range.
It supports:
- filling empty cells with
NAor custom text - skipping one or more excluded ranges
- optionally merging contiguous empty cells vertically within a column before filling them
- preserving comment-only cells without filling or merging them
- working against the active worksheet or a named sheet
The implementation uses openpyxl to inspect workbook contents and compute fill operations, then patches only the target worksheet XML inside the workbook archive when saving. That keeps existing drawings, charts, images, and other unsupported workbook parts intact instead of round-tripping the whole file through openpyxl.save(). .xlsx and .xlsm are supported. .xls is not supported.
Pillow is not required to preserve existing workbook images. It is only relevant if you want to create new images through openpyxl itself. The committed test fixture under tests/fixtures/ does not require Pillow at test runtime.
Install
From PyPI:
pip install excel-fill-na
From a local checkout:
pip install .
For development:
python3 -m venv .venv
.venv/bin/python -m pip install -e ".[dev]"
CLI Usage
fna workbook.xlsx \
--sheet Sheet1 \
--range A1:C20 \
--exclude-range B2:B4 \
--exclude-range C10 \
--fill-text MISSING \
--merge-empty-runs \
--output workbook.filled.xlsx
CLI options
input_path: source workbook path--sheet: worksheet name, defaults to the active sheet--range: target range to inspect, required--exclude-range: ranges to leave untouched; repeat the flag or pass comma-separated ranges--fill-text: replacement text, defaults toNA--merge-empty-runs: merge contiguous empty cells vertically within each column before filling--output: destination path, defaults to<input>.filled<suffix>
Python Usage
from excel_fill_na import process_workbook
result = process_workbook(
"workbook.xlsx",
target_range="A1:C20",
excluded_ranges=["B2:B4", "C10"],
fill_value="NA",
merge_empty_runs=True,
)
print(result.output_path)
print(result.filled_cells)
print(result.merged_ranges)
Merge behavior
When merge_empty_runs=True, the library scans each column in the selected range and looks for contiguous empty cells. Runs of length 2 or more are merged vertically and the top cell is filled with the requested value.
Example:
A1,A2, andA3are emptyA4contains data- target range is
A1:A4 - merge mode creates
A1:A3and fillsA1withNA
Existing merged cells are supported. If an existing merged range has an eligible empty anchor cell, the anchor is filled, but the library does not attempt to re-merge or resize that existing merged range.
Comment behavior
Only truly empty cells are modified. If a cell has no value but does have a comment, the library preserves that cell as-is:
- it is not filled with
NAor custom text - it is not included in a generated merge run
- it breaks a vertical empty run when
merge_empty_runs=True
Cells that already contain a value are untouched regardless of whether they also have a comment.
Specs
- Functional spec:
docs/FUNCTIONAL_SPEC.md - CLI spec:
docs/CLI_SPEC.md
Tests
.venv/bin/pytest
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 excel_fill_na-0.1.1.tar.gz.
File metadata
- Download URL: excel_fill_na-0.1.1.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adaeb00d8c9eac756f771df388330cd3453e4efbe118d8eff5b315ecd77756de
|
|
| MD5 |
ad0566e205cc6e690bb0331d6ef9d321
|
|
| BLAKE2b-256 |
04ba6bc113189e8fc7efb15cc6e962054e02921fafa2e62ce54719919969491c
|
Provenance
The following attestation bundles were made for excel_fill_na-0.1.1.tar.gz:
Publisher:
publish.yml on dews/excel-fill-na
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
excel_fill_na-0.1.1.tar.gz -
Subject digest:
adaeb00d8c9eac756f771df388330cd3453e4efbe118d8eff5b315ecd77756de - Sigstore transparency entry: 1244252963
- Sigstore integration time:
-
Permalink:
dews/excel-fill-na@3eabde92441a94c93adaf3687198ae41ab8e8d9c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/dews
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3eabde92441a94c93adaf3687198ae41ab8e8d9c -
Trigger Event:
release
-
Statement type:
File details
Details for the file excel_fill_na-0.1.1-py3-none-any.whl.
File metadata
- Download URL: excel_fill_na-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.5 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 |
0483d3a1136f81ee76254bb5f88b979422b8d32553e984496ece0870190eae76
|
|
| MD5 |
21b86173b1b33b562c611ab4c8bef66d
|
|
| BLAKE2b-256 |
9755e30e2474e8ea49d78bb2ff2e3e06ab40ed81c4cdb779b4f10a30e338f104
|
Provenance
The following attestation bundles were made for excel_fill_na-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on dews/excel-fill-na
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
excel_fill_na-0.1.1-py3-none-any.whl -
Subject digest:
0483d3a1136f81ee76254bb5f88b979422b8d32553e984496ece0870190eae76 - Sigstore transparency entry: 1244252978
- Sigstore integration time:
-
Permalink:
dews/excel-fill-na@3eabde92441a94c93adaf3687198ae41ab8e8d9c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/dews
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3eabde92441a94c93adaf3687198ae41ab8e8d9c -
Trigger Event:
release
-
Statement type: