Add cross-platform OOXML backend alongside Windows Excel COM
Linux/macOS default to surgical zip edits that clear/set cells while preserving queries, styles, and other non-worksheet parts. Windows keeps the COM + add-in path. Paths remapped via XLSX_CLEAN_ROOT; pywin32 is Windows-only. Co-authored-by: Diaco Soltanpour <s-diaco@users.noreply.github.com>
This commit is contained in:
48
AGENTS.md
48
AGENTS.md
@@ -1,28 +1,37 @@
|
||||
# xlsx-clean
|
||||
|
||||
`xlsx-clean` is a small **Windows-only** Python CLI (`src/xlsx_clean/clean_cells.py`) that
|
||||
generates a new Excel QC datasheet from the most recent workbook in a configured directory,
|
||||
clearing/resetting specific cells via Microsoft Excel COM automation (`pywin32`).
|
||||
`xlsx-clean` is a Python CLI (`src/xlsx_clean/clean_cells.py`) that generates a new
|
||||
Excel QC datasheet from the most recent workbook in a configured directory,
|
||||
clearing/resetting specific cells.
|
||||
|
||||
## Backends
|
||||
|
||||
- **`com` (Windows default):** Microsoft Excel COM via `pywin32`. Loads add-ins listed
|
||||
in `strings.txt`, edits cells, `SaveAs`, leaves Excel visible/maximized.
|
||||
- **`ooxml` (Linux/macOS default):** Surgical edit of the `.xlsx` zip (worksheet XML
|
||||
only). Preserves non-worksheet parts (styles, connections/Power Query definitions,
|
||||
drawings, etc.). Does not calculate formulas or refresh queries.
|
||||
|
||||
Select with `--backend com|ooxml`.
|
||||
|
||||
## Cursor Cloud specific instructions
|
||||
|
||||
### Platform limitation (important)
|
||||
- The app is **Windows-only** and **cannot run end-to-end on this Linux VM**:
|
||||
- `pywin32` has no Linux wheels, so it is intentionally **not** installed here.
|
||||
- `src/xlsx_clean/clean_cells.py` imports `win32com.client` at module top level and drives
|
||||
the desktop **Microsoft Excel** app via COM, plus reads `D:\OpenCloud\...` Windows paths
|
||||
from `src/xlsx_clean/file_data.csv`. None of that exists on Linux.
|
||||
- What **does** run on Linux: everything except the Excel COM layer, i.e. the config/data
|
||||
logic (reading `strings.txt` + `file_data.csv` with `pandas`, resolving the set/ink-color
|
||||
selection, and computing the new workbook filename from the `[SERIAL]` pattern).
|
||||
### Platform notes
|
||||
- `pywin32` has no Linux wheels and is declared as Windows-only
|
||||
(`pywin32>=306; sys_platform == 'win32'`). It is intentionally **not** installed here.
|
||||
- End-to-end COM automation needs Windows + desktop Excel and does not run on this VM.
|
||||
- On Linux, the **ooxml** backend can clear/set cells and write a new workbook when
|
||||
sample files and `XLSX_CLEAN_ROOT` point at a real tree. Without those data files,
|
||||
interactive selection still works for config loading, but globbing finds no templates.
|
||||
|
||||
### Environment
|
||||
- Dependencies are installed into a `uv`-managed virtualenv at `.venv` by the startup update
|
||||
script (`uv` itself is installed via `pip install --break-system-packages uv` and lives in
|
||||
`~/.local/bin`, which is on PATH for interactive shells via `~/.bashrc`).
|
||||
- The install faithfully uses pinned versions from `requirements.lock`, excluding the `-e file:.`
|
||||
- Dependencies are installed into a `uv`-managed virtualenv at `.venv` by the startup
|
||||
update script (`uv` itself is installed via `pip install --break-system-packages uv`
|
||||
and lives in `~/.local/bin`, which is on PATH for interactive shells via `~/.bashrc`).
|
||||
- The install uses pinned versions from `requirements.lock`, excluding the `-e file:.`
|
||||
editable line and `pywin32`; the package is then installed editable with `--no-deps`.
|
||||
- Run Python via the venv interpreter: `.venv/bin/python`.
|
||||
- Optional: `XLSX_CLEAN_ROOT` remaps `D:\OpenCloud\...` paths from `file_data.csv`.
|
||||
|
||||
### Lint / test / build
|
||||
- There is **no lint config, no test suite, and no build step** in this repo (no ruff/flake8,
|
||||
@@ -30,8 +39,7 @@ clearing/resetting specific cells via Microsoft Excel COM automation (`pywin32`)
|
||||
- `pyproject.toml` uses `hatchling` as the build backend; there is nothing to "build" for dev.
|
||||
|
||||
### Running / verifying
|
||||
- The interactive tool (`cd src/xlsx_clean && python clean_cells.py`) needs Windows + Excel and
|
||||
will fail on import here — do not expect it to run on the VM.
|
||||
- To sanity-check the environment on Linux, verify imports and the package:
|
||||
`.venv/bin/python -c "import pandas, beaupy; from xlsx_clean import hello; print(hello())"`.
|
||||
- Interactive tool: `.venv/bin/python -m xlsx_clean.clean_cells` (defaults to `ooxml` on Linux).
|
||||
- Sanity-check imports:
|
||||
`.venv/bin/python -c "import pandas, beaupy; from xlsx_clean import hello; from xlsx_clean.ooxml_backend import expand_a1_range; print(hello(), expand_a1_range('A1:B2'))"`.
|
||||
- Note: the `uv`-created `.venv` does not include `pip`; use `uv pip ...` for package operations.
|
||||
|
||||
Reference in New Issue
Block a user