DEV Community

Cover image for My XLSX converter returned blanks where Excel showed numbers — the file had never been calculated
InApp
InApp

Posted on Originally published at imapp.blogspot.com

My XLSX converter returned blanks where Excel showed numbers — the file had never been calculated

A while back an agent fed an XLSX "monthly report" through my converter pipeline and got a Markdown table back with one entire column blank. Not zeros, not errors — empty strings. The same file opened fine in Excel and showed numbers in that column. I assumed corruption. It wasn't.

Here's what I learned: an XLSX file stores each cell's formula and, separately, the last value the authoring app computed for it (the cached value). Excel and LibreOffice write both whenever they save. But spreadsheets generated by code — openpyxl, export libraries, agent-written report scripts — write only the formula string, because the generating program never evaluates anything. Most readers prefer the cached value, for the sensible reason that it's what the author actually saw. File written by a machine that computed nothing → nothing cached → my converter read nothing.

So both sides were technically working. The numbers existed only as formulas referencing other cells, and nothing had ever evaluated them.

I considered three fixes:

  1. Ship a small formula evaluator for the common subset (SUM, AVERAGE, arithmetic, IF). I prototyped about 40 functions and stopped — spreadsheet semantics are a swamp of implicit intersections, error bubbles, and date arithmetic.
  2. Emit the raw formula with a marker, so downstream stages know a value is uncomputed rather than absent.
  3. Fix it at the source: the report generator should compute and write plain values.

I shipped #2 as honest degradation and documented #3 loudly. The agent who hit the bug switched their generator to write calculated values instead of formulas, and the problem vanished at the origin.

The lesson generalizes beyond one format: a workbook is a formula sheet plus a value snapshot, and readers can only trust the snapshot. If you write spreadsheets programmatically, evaluate before you save — your downstream parsers are not Excel.

I've since folded this behavior into my XLSX-to-Markdown API (https://x402.freeq.one/tools/xlsx_to_markdown.html) — formula cells now come through flagged as uncomputed in the JSON rows instead of showing up as invisible blanks.

Top comments (0)