- JavaScript 77.1%
- Python 16.1%
- TypeScript 4.8%
- CSS 0.8%
- HTML 0.6%
- Other 0.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PVUe4hWqPfFUKC4KEEmcM2 |
||
| .forgejo/workflows | ||
| app | ||
| browser | ||
| check | ||
| fixtures | ||
| scripts | ||
| test | ||
| .gitignore | ||
| .npmrc | ||
| .prettierignore | ||
| .prettierrc | ||
| LICENSE.md | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
@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 also1,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.234is 1234,1.234,5is 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'234and1 234with a plain space are text (t: "s"), as are12,5 %and13,50 €.1.2.2024is 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.