@aivopod/sheets (1.2.0)

Published 2026-11-28 21:05:58 +01:00 by oliver.maklott in aivopod-shared/sheets

Installation

@aivopod:registry=
npm install @aivopod/sheets@1.2.0
"@aivopod/sheets": "1.2.0"

About this package

@aivopod/sheets

Reads Excel workbooks (.xlsx) and CSV files in the browser, for Aivopod packs that check work students did in a spreadsheet program. Plan 26 of Aivopod (docs/PLAN-26.md in aivopod-app, Teil AZ of its docs/SPEC.md).

Part What
browser/ classic scripts on window.AivopodSheets, no build: xml, zip, formula, xlsx, csv. They run as they are back to Safari 15.4.
app/ the table bridge: a pack app that reads the file a student picks and answers what a step asks for (settings.cells); it loads the scripts from vendor/
fixtures/ lerndaten/: the workbooks of Meine-Lerndaten 1.4.1 (made by scripts/lerndaten-fixtures.py, openpyxl); reader/: scripts/build-fixtures.py

The reader came from the Excel bridge of the pack Meine-Lerndaten (1.4.1). test/legacy/ holds that reader; a test reads every workbook of the pack with both and requires the library to return everything the old reader did, with the same values.

Packs take the library through aivopod.vendor in their package.json; aivopod pack build copies the parts into the pack (Teil AZ, D516).

Findings per cell

A step asks with settings.cells: ranges and the fields wanted, at most 400 cells. The answer has only those fields, and only where they differ from the default. It always fits the platform's limit (15 500 characters): when it would not, texts and formulas get shorter, then cells at the end are left out, and trimmed says so. Fields and the answer's shape: browser/cells.js, test/schema.mjs.

A step names its sheet with settings.sheet. Without one, the bridge reads the first visible sheet that holds a value or a formula (1.1.0): Excel's "Daten abrufen ▸ Aus Text/CSV ▸ Laden" puts the data on a new sheet beside the empty "Tabelle1" of a new workbook.

What a file is

The bytes decide what a file is (cells.detect), never its name: a workbook is a ZIP archive with a workbook part, so a .docx or .pptx is unbekannt and not a workbook without sheets; an OpenDocument file is ods only when it is a spreadsheet; a CSV file is text, so a picture, a PDF, an RTF or HTML file or anything with control characters is unbekannt. A workbook with macros or of a macro format is makro-datei; a workbook merely named .xlsm is read. detect never throws. xlsx.read throws only Error("zip:…"), Error("xml:…") or Error("xlsx:…"): xlsx:no-workbook for an Office file that is no workbook, xlsx:broken (with cause) for a damaged one.

Numbers in CSV files

A CSV file has no types, so the library reads its fields the way a German Excel does, by one rule (csv.number; csv.num, the cells of a CSV file and its decimalComma all follow it):

  • The comma is the decimal sign: 0,45, 1234,5, and also 1,234 (1.234, not 1234).
  • A point is a thousands separator, and only between groups: one to three digits that do not start with 0, then groups of exactly three: 1.234 is 1234, 1.234,5 is 1234.5. A no-break space (U+00A0, U+202F) groups the same way: the Unicode locale data (CLDR), which Apple's programs follow, group like that for Austria.
  • A point is never a decimal sign. 0.59, 1.5, 0.125, 1.2345, 1,234.5, 1'234 and 1 234 with a plain space are text (t: "s"), as are 12,5 % and 13,50 €. 1.2.2024 is a date.

So the ambiguous 1.234 is always 1234. csv.num is for apps that read fields themselves: the same rule first, and for everything else a plain JavaScript number (0.59 is 0.59) or null.

Checker core

@aivopod/sheets/check (TypeScript, no runtime dependencies) goes into a pack's checker: answerOf(answer, { accept, template, calculated }) gives the answer or a basis error with a fixed ID (sheets.keine-datei, sheets.nur-csv, sheets.nur-xlsx, sheets.makro-datei, sheets.falsches-format, sheets.falsche-vorlage, sheets.nicht-berechnet, sheets.blatt-fehlt); the pack has texts for them under feedback.sheets.*. The template counts by <pack>/<file>, not by its version. Helpers say facts about cells (samePattern, constantsIn, allBorders, merged, near, …); the verdict and its feedback are the pack's.

Vendoring into a pack

aivopod-vendor.json (written by npm run build) names what a pack may copy and the SHA-256 of each file: the browser scripts in load order, the app tabellen-bruecke (scripts go into its vendor/) and the checker core. A pack names the package under aivopod.vendor in its package.json; aivopod pack build copies the files and refuses changed ones (D516).

Develop

npm install
npm run check              # prettier and the tests (node --test)
python3 scripts/build-fixtures.py   # rebuild fixtures/reader (Python 3, no libraries)

A new version in package.json on main is published by CI to the npm registry of the aivopod organisation (scripts/publish.sh, secret PACKAGE_TOKEN).

License

FSL-1.1-ALv2, see LICENSE.md.

Dependencies

Development dependencies

ID Version
@aivopod/analysis 0.68.0
prettier ^3.9.10
typescript ~6.0.3
valibot ^1.5.0
Details
npm
2026-11-28 21:05:58 +01:00
2
FSL-1.1-ALv2
latest
33 KiB
Assets (1)
Versions (3) View all
1.2.0 2026-11-28
1.1.0 2026-11-23
1.0.0 2026-11-10