41 lines
1.5 KiB
Markdown
41 lines
1.5 KiB
Markdown
---
|
|
layout: post
|
|
title: "wbc: generating xlsx"
|
|
author: jadudm
|
|
draft: true
|
|
# commit: https://github.com/jadudm/pytbl/tree/527b16bdecbf73b874103922cf3038a1f2c1e1c7
|
|
tags:
|
|
- cc-sa
|
|
- wbc
|
|
- blog
|
|
- "2025"
|
|
- 2025-09
|
|
date: 2025-09-16
|
|
---
|
|
|
|
Generating Excel workbooks in code is hard. By this, I mean that writing code that outputs an XLSX document involves a lot of details (contents, formatting, data validations), and you have to learn a lot about XLSX in order to do it right.
|
|
|
|
**But Matt: who would ever want to generate Excel documents from code?**
|
|
|
|
It turns out, most everyone who works with data. Also, *every government everywhere*. Spreadsheets are the lifeblood of governments around the world. Also, financial institutions. And researchers. And... and...
|
|
|
|
## a workbook "compiler"
|
|
|
|
For a number of months (years?), I've been thinking about writing a workbook "compiler." In technical terms, a compiler transforms one language or representation of content to another while preserving the intention of the programmer. In this case, I want a way to express a workbook in one language (say, a textual representation like JSON) and I want to transform it to another representation (an XLSX document, or spreadsheet).
|
|
|
|
For example, I'd like to be able to say write something like this:
|
|
|
|
```json
|
|
{
|
|
"workbook": "my first spreadsheet",
|
|
"sheets": [
|
|
{
|
|
"name": "empty sheet"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
and run a program that consumes that textual file, producing as output the XLSX document.
|
|
|