code wiki / _hdl_build / nx_xlsx.nx
nx_xlsx.nx
buildroot/runtime/_hdl_build/nx_xlsx.nx
about
nx_xlsx.nx -- SOVEREIGN MS-Excel (.xlsx / SpreadsheetML) interop for the Nishi Office suite. A .xlsx is an OPC
package (framed by the shared nx_opc, same ZIP as .docx) with 5 parts:
[Content_Types].xml, _rels/.rels, xl/workbook.xml, xl/_rels/workbook.xml.rels, xl/worksheets/sheet1.xml
fromtsv : a tab-separated grid -> a valid Excel-openable .xlsx (numeric cells as <v>, text as inlineStr;
cell text XML-escaped). Use case: an estate asset SCHEDULE / valuation workbook.
read : a .xlsx -> the sheet1 grid back as TSV (handles our inlineStr + numeric cells).
Sovereignty = our own SpreadsheetML; rigor = the harness proves a 3rd-party (python zipfile) opens our .xlsx
with valid CRC-32s and the expected cell values.
HONEST LIMITATION: read supports inlineStr + numeric <v>; a real Excel file that uses a sharedStrings table
(t="s") would yield string INDICES not text -- sharedStrings read is a follow-on. Sparse columns are emitted
in document order (dense round-trip is exact; gaps are not repositioned).
nx_xlsx fromtsv <in.tsv> <out.xlsx> | nx_xlsx read <in.xlsx>
license_tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.nxnx_opc.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 120 | struct XfGrid |
consts
| 17 | const XF_MAGIC_10000: i64 = 10000 |
| 18 | const XF_MAGIC_8388624: i64 = 8388624 |
| 19 | const XF_MAGIC_4194320: i64 = 4194320 |
| 20 | const XF_MAGIC_4194304: i64 = 4194304 |
| 21 | const XF_MAGIC_8388608: i64 = 8388608 |
| 22 | const XF_MAGIC_1048592: i64 = 1048592 |
| 23 | const XF_MAGIC_16384: i64 = 16384 |
| 24 | const XF_MAGIC_33554432: i64 = 33554432 |
| 25 | const XF_MAGIC_1048576: i64 = 1048576 |
| 117 | const XF_MAXC: i64 = 64 |
| 118 | const XF_MAXR: i64 = 1024 |
| 538 | const XL_MAXR: i64 = 512 |
| 539 | const XL_MAXC: i64 = 64 |
| 540 | const XL_CELLW: i64 = 40 |
functions
| 27 | func xl_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 32 | func xl_num(v: i64) -> i64 { nxi_out(v); return 0 } |
| 33 | func xl_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 } |
| 34 | func xl_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 35 | func xl_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ dst[off+i]=s[i]; i=i+1 } return off+i } |
| 36 | func xl_uint(dst: *u8, off: i64, v: i64) -> i64 { var m: i64=v; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var o: i64=off; var i: i64=0; while i<k{dst[o]=t[k-1-i];o=o+1;i=i+1} return o } called by 7: xl_emit_cellxl_build_sheetxf_fmtq4xl_build_sheet_gxl_styles_dxfxl_chart_html+1 calls 1: sys_mmap |
| 37 | func xl_match(buf: *u8, pos: i64, n: i64, pat: *u8) -> i64 called by 1: xlsx_write_tsv |
| 41 | func xl_col(dst: *u8, off: i64, idx: i64) -> i64 |
| 47 | func xl_is_numeric(src: *u8, soff: i64, slen: i64) -> i64 |
| 63 | func xl_escape_region(out: *u8, o: i64, src: *u8, soff: i64, slen: i64) -> i64 |
| 73 | func xl_emit_cell(out: *u8, o: i64, col: i64, row: i64, src: *u8, soff: i64, slen: i64) -> i64 called by 2: xl_build_sheetxl_build_sheet_g calls 5: xl_catxl_colxl_uintxl_is_numericxl_escape_region |
| 88 | func xl_build_sheet(tsv: *u8, tn: i64, out: *u8) -> i64 |
| 134 | func xf_grid_new(tsv: *u8) -> *XfGrid |
| 150 | func xf_ws(s: *u8, ip: *i64, e: i64) -> i64 |
| 156 | func xf_q4_of(s: *u8, off: i64, len: i64) -> i64 |
| 173 | func xf_fmtq4(dst: *u8, off: i64, v: i64) -> i64 |
| 196 | func xf_refparse(s: *u8, ip: *i64, e: i64, rc: *i64) -> i64 |
| 216 | func xf_cellnum(g: *XfGrid, r: i64, c: i64) -> i64 |
| 237 | func xf_factor(g: *XfGrid, ip: *i64, e: i64) -> i64 |
| 354 | func xf_term(g: *XfGrid, ip: *i64, e: i64) -> i64 |
| 376 | func xf_expr(g: *XfGrid, ip: *i64, e: i64) -> i64 |
| 397 | func xf_evalcell(g: *XfGrid, r: i64, c: i64) -> i64 |
| 412 | func xf_load(g: *XfGrid, tsv: *u8, tn: i64) -> i64 |
| 477 | func xl_build_sheet_g(g: *XfGrid, tsv: *u8, tn: i64, out: *u8) -> i64 |
| 542 | func xl_dir_is(buf: *u8, s: i64, e: i64, tag: *u8) -> i64 |
| 549 | func xl_tok(buf: *u8, p: i64, e: i64, out: *u8, cap: i64, np: *i64) -> i64 |
| 558 | func xl_atoi_s(s: *u8) -> i64 |
| 567 | func xl_macro_apply(tsv: *u8, n: i64, out: *u8, cap: i64) -> i64 |
| 689 | func xl_styles_dxf() -> *u8 |
| 694 | func xl_emit_cf_dv(out: *u8, off: i64, tsv: *u8, n: i64) -> i64 |
| 762 | func xlsx_write_tsv(tsvpath: *u8, outpath: *u8) -> i64 |
| 805 | func xl_shared_load(path: *u8, sbuf: *u8, soffs: *i64, maxn: i64) -> i64 |
| 845 | func xlsx_read_tsv(path: *u8, out: *u8, cap: i64) -> i64 |
| 916 | func xl_esc1(dst: *u8, o: i64, c: i64) -> i64 |
| 924 | func xl_rowhtml(out: *u8, off: i64, tsv: *u8, s: i64, e: i64, ishdr: i64) -> i64 |
| 950 | func xl_chart_html(out: *u8, off: i64, tsv: *u8, tn: i64) -> i64 |
| 1066 | func xl_tsv_to_html(tsv: *u8, tn: i64, out: *u8, dlurl: *u8, label: *u8) -> i64 |
| 1091 | func xlsx_to_html(path: *u8, out: *u8, dlurl: *u8) -> i64 |
| 1103 | func xl_colletter(s: *u8) -> i64 |
| 1117 | func xl_pivot(tsv: *u8, tn: i64, gc: i64, vc: i64, pout: *u8) -> i64 |
| 1212 | func main(argc: i64, argv: *i64) -> i64 |