Files
xlsx-clean/README.md
Cursor Agent d46fe5b6a4 Add modern Desktop icon and bring Excel to front on COM save
Ship a multi-size teal spreadsheet ICO for shortcuts/exe, and after COM
SaveAs maximize Excel and force it to the foreground over the app window.

Co-authored-by: Diaco Soltanpour <s-diaco@users.noreply.github.com>
2026-07-22 09:51:18 +00:00

4.8 KiB

xlsx-clean

Create a new QC datasheet from the latest matching workbook: clear configured cells, blank notes, write the batch serial, and save under a new [SERIAL] name.

Everyday use is a Desktop icon that opens a single app window (Set → Ink → Serial → Create) — not your full browser with all tabs. No terminal commands are required for operators.

Quick start (Windows operators)

  1. One-time setup (IT / first install): install uv, clone/copy this project, then double-click
    desktop\Setup.bat
  2. Every day: double-click the XlsxClean icon on the Desktop
  3. In the app window: choose Set, Ink color, enter Serial, click Create datasheet

Setup.bat creates .venv with uv, installs the package, and adds the Desktop shortcut (using the modern icon in desktop\xlsx-clean.ico). The shortcut runs desktop\XlsxClean.vbs and opens one dedicated window (via pywebview). Closing that window stops the app.

When you Create with the com backend, Excel is maximized and brought to the front after the new workbook is saved.

If something fails, use desktop\XlsxClean.bat instead — it shows a console with errors. To force the old “open in default browser” behavior for debugging:

.venv\Scripts\python.exe -m xlsx_clean.web_app --browser

Standalone Windows exe (optional)

To put a self-contained app on other PCs (build on Windows):

  1. Install uv if needed
  2. Double-click desktop\build_windows_exe.bat
  3. It creates dist\XlsxClean\XlsxClean.exe and a Desktop shortcut
  4. Copy the whole dist\XlsxClean\ folder when moving to another machine (keep files together)

What the app does

Step Action
1 Find the latest matching workbook in the product folder
2 Clear configured cells / blank notes
3 Write the batch serial
4 Save as a new file using the [SERIAL] name pattern

Excel backends

Platform Default Notes
Windows com Uses Microsoft Excel + add-ins from strings.txt; leaves Excel open
Linux / macOS ooxml Surgical .xlsx edit; keeps formulas, formatting, and queries on disk

Choose the backend in the web UI dropdown, or with CLI --backend com\|ooxml.

Limits of ooxml: does not refresh Power Query, calculate formulas, or load .xlam/.xla add-ins. Open the file in Excel afterward for refresh/calc. Prefer com on Windows when you need add-ins and a live Excel session.

First-time install (admins)

Uses uv (not pip). Install uv once: https://docs.astral.sh/uv/getting-started/installation/

Windows (recommended): double-click desktop\Setup.bat

Manual / Linux / macOS (from the project root):

uv venv .venv
uv pip install -e . -p .venv/bin/python   # Windows: .venv\Scripts\python.exe

Before building the standalone exe, also install packaging extras:

uv pip install -e ".[desktop]" -p .venv/bin/python

Then create the Desktop shortcut (if you did not use Setup.bat):

  • Windows: double-click desktop\Install-DesktopShortcut.bat
  • Linux: .venv/bin/python desktop/install_desktop_shortcut.py

Optional: set XLSX_CLEAN_ROOT if workbooks are not under D:\OpenCloud (e.g. set XLSX_CLEAN_ROOT=D:\OpenCloud or export XLSX_CLEAN_ROOT=/mnt/opencloud).

Developer interfaces

These are optional; operators should use the Desktop icon.

App window (default: native single window)

.venv/bin/python -m xlsx_clean.web_app
# Windows: .venv\Scripts\python.exe -m xlsx_clean.web_app

# Optional: open in the default browser instead
.venv/bin/python -m xlsx_clean.web_app --browser

CLI

.venv/bin/python -m xlsx_clean.clean_cells --backend ooxml

Windows CLI helper: src\xlsx_clean\new_xslx.bat

Config files

File Purpose
src/xlsx_clean/file_data.csv Product folders, filename patterns, cells to clear/set
src/xlsx_clean/strings.txt UI prompts + Windows Excel add-in paths (com only)
XLSX_CLEAN_ROOT (env) Replaces the D:\OpenCloud\... root in CSV paths

Project layout (launchers)

Path Purpose
desktop/xlsx-clean.ico Modern Windows Desktop / exe icon
desktop/Setup.bat Windows one-time setup via uv + Desktop shortcut
desktop/Install-DesktopShortcut.bat Create Desktop icon only (Windows)
desktop/XlsxClean.vbs Silent double-click launcher
desktop/XlsxClean.bat Launcher with visible console
desktop/build_windows_exe.bat Build standalone XlsxClean.exe with uv
desktop/install_desktop_shortcut.py Create Desktop shortcut (Linux)
packaging/xlsx_clean.spec PyInstaller spec