.xlsx(@awacloud/ooxml'sxlsx.read()result) →oconv-ir/v2, tier 2 — one heading + one table per sheet.
Module oconvXlsxToIr (oconvXlsxToIr) | Source packages/front/office/oconv/src/read/xlsx-to-ir.js | Deps oconvIr, xlsx | Worker-safe yes
Pure transformation over an already-parsed xlsx.read(bytes) structure. Composes only xlsx's public API, never an @awacloud/ooxml internal.
Resolve
import { ModuleRuntime } from '@awacloud/fw/core/runtime.js';
import { fw_require, modules } from '@awacloud/oconv';
const runtime = new ModuleRuntime();
runtime.registerAll(fw_require);
runtime.registerAll(modules);
const xlsx = runtime.resolve('xlsx');
const { xlsxToIr } = runtime.resolve('oconvXlsxToIr');
API
| Member | Signature | Returns | Throws |
|---|---|---|---|
xlsxToIr |
(readResult: object, opts?: object) => {ir, losses} |
ir — an oconv-ir/v2 document; losses — {code, detail}[] |
— |
Examples
Convert an .xlsx read result to IR
const { ir, losses } = xlsxToIr(xlsx.read(bytes));
ir.kind; // 'document'
losses; // [] on a plain grid with no formulas/styles/merges/charts
Notes
- One IR
heading{level:1}+ one IRtableper workbook sheet, in workbook order — the heading is always level 1 (sheets carry no nesting signal to derive a deeper level from). - The sheet's row grid is padded to its widest row, then trailing all-empty rows/columns are trimmed (
normalizeGrid, mirrored fromread/sheet-grid.js); a sheet whose trimmed grid has zero rows emits its heading only. - No
row.headeris ever set — xlsx carries no first-class header-row concept (contrastoconvOdsToIr, whosetable:table-header-rowsis a real signal). opts.sheets(toMd'ssheetsinput):'table'(default) maps each sheet to a GFM table as above;'csv'or'tsv'writes the same normalised grid as onecodeBlock(infocsv/tsv) under the sheet's heading — RFC 4180 quoting for csv; for tsv a cell's backslash, tab, LF and CR written as two-character escapes, recorded once per sheet assheet/tsv-escaped. Another value throwsoconv: bad sheets.opts.cellBudget(toMd'ssheetCellBudgetinput): a positive safe integer, elseoconv: bad cell budget; 5,000,000 when absent (since 2.0.0). A sheet whose padded table (its kept rows times its kept columns, found from the row lengths without padding) would hold more cells is never padded: under'table'oneparagraphper non-empty cell,<A1 address>: <text>, in row then column order; under'csv'/'tsv'its rows unpadded. Recordedsheet/sparse-form(the sheet name, the padded and the kept cell counts).Number.MAX_SAFE_INTEGERpads every sheet as above, as 1.x did without the option.- Loss codes this module emits:
sheet/formula-as-value(a formula cell reduced to its cached value),sheet/format-dropped(once per sheet, first styled cell),sheet/merge-dropped(once per sheet, when any merge exists),sheet/chart-dropped(once per sheet, first drawing carrying a chart). - Pivot tables are a matrix-level, permanently out-of-scope drop — this reader's frozen dependency list never wires the opt-in pivot-table extension, so a pivot table is structurally invisible on the
readResultit receives; never reported per node.
See also
- docs/api/README.md — full module index +
exportsboundary note oconvIr— the pivot this reader producesoconvOdsToIr— the ODF sister reader, same loss vocabulary- loss matrix