Stripping Excel Pivot Caches, Bank Memos, and PII Inside a Single Offline HTML File

2026-12-05来源 dev.toEnglish

Deleting the email and phone columns in Excel before sharing a spreadsheet rarely makes it safe.

When I started inspecting real e-commerce and ERP exports (Shopify, Amazon, TikTok Shop, bank statements), four leaks showed up repeatedly even after people manually scrubbed customer columns:

  1. Excel hidden residue: xl/pivotCache/ XML files still hold cached source records from deleted columns; workbook properties keep author and company names; hidden sheets and cell comments survive casual edits.
  2. Free-text bank memos: Transfer descriptions routinely embed counterparty names, IBANs, and VAT numbers (ZELLE FROM JOHN DOE · IBAN GB29...).
  3. Commercial identity: Even with customer PII gone, store names, SKU codes, supplier names, and exact revenue totals still expose business margins and vendors.
  4. Irreversible redaction: Once you replace values with ***, you cannot map findings from an external audit back to the original orders.

Here is how I built a zero-network, single-file browser sanitizer to solve those four issues without requiring a server.

1. Enforcing zero network egress at the browser layer

Instead of asking users to trust a privacy promise, the standalone HTML file ships with a strict Content Security Policy:

<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'"> 

With connect-src 'none', fetch, XMLHttpRequest, and sendBeacon are blocked by the browser engine itself. All JS and CSS are inlined at build time into a single ~630 KB HTML file that runs from file:// with Wi-Fi turned off.

2. Inspecting Excel ZIP internals before flattening to CSV

An .xlsx file is a ZIP archive. Before exporting a clean UTF-8 CSV, the parser inspects the archive entries for:

  • docProps/core.xml and docProps/app.xml (author, last modified by, company)
  • Hidden worksheet flags in xl/workbook.xml
  • xl/comments*.xml and formula cells
  • xl/pivotCache/ and xl/externalLinks/

Exporting strictly evaluated cell values to a fresh UTF-8 CSV drops all of those structures automatically, while surfacing a report of what was stripped.

3. Preserving accounting math while hiding revenue scale

Sometimes you want an outside analyst to check net margin or fee percentages without revealing whether your store does $50k or $5M a month.

Multiplying every monetary column by a single local random factor k keeps every ratio, margin percentage, and fee discrepancy proportional. The factor is stored only inside the local key file (_meta.scaleFactor), so when the audit report comes back in JSON or CSV, dividing by k restores exact figures locally. (The UI explicitly notes to keep scaling off when fixed statutory tax thresholds matter.)

4. Encrypting the local key file with Web Crypto

Because the local mapping JSON can reverse every token, leaving it in plain text on a shared drive is its own risk. Using native crypto.subtle:

  • Derive a 256-bit AES-GCM key from an optional user passphrase via PBKDF2-SHA256 (210,000 iterations, random 16-byte salt).
  • Encrypt the JSON vault with a random 12-byte IV.
  • Store the encrypted envelope locally; decryption happens only in memory during restore.

5. Full-sheet verification pass

Before any file downloads, a second verification pass scans 100% of output rows and cells against the PII, commercial, and custom-term detectors. If anything slipped through a kept text column, export pauses and lists the remaining hits. In benchmarks, sanitizing and verifying 50,000 rows takes ~600 ms in V8.

I built this as the free offline front-end for Tanramisu, a row-cited payout reconciliation and tax summary tool. If you want to test the sanitizer directly (there is a built-in sample sheet, no login needed), it lives at clean.tanramisu.com.

原文:https://www.a8q9.cn/en/article/stripping-excel-pivot-caches-bank-memos-and-pii-inside-a-single-offline-html-fil-75e628.html

相关文章