javascript-excel 2.0.0-alpha.2 → 2.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +151 -21
  2. package/dist/address-DUn7-5OS.js +75 -0
  3. package/dist/address-DZBHchLv.cjs +122 -0
  4. package/dist/{auto-width-2oBzjeNG.d.cts → auto-width-DRHsPKNk.d.cts} +1 -1
  5. package/dist/cells-CPXU722t.cjs +33 -0
  6. package/dist/cells-CrMF8h_t.js +28 -0
  7. package/dist/colors-B8Nf_xTx.js +114 -0
  8. package/dist/colors-oBpjx97l.cjs +119 -0
  9. package/dist/csv.d.cts +4 -1
  10. package/dist/csv.d.ts +4 -1
  11. package/dist/dataset-KeMzHCGl.js +664 -0
  12. package/dist/dataset-UUZCzsi3.cjs +687 -0
  13. package/dist/dates-BXcSWf9_.js +64 -0
  14. package/dist/dates-CA1dCizp.cjs +75 -0
  15. package/dist/dom.cjs +5 -2
  16. package/dist/dom.d.cts +5 -2
  17. package/dist/dom.d.ts +4 -1
  18. package/dist/dom.js +4 -1
  19. package/dist/{numfmt-Dv6AjopS.cjs → dos-time-FZ7-1tot.cjs} +0 -199
  20. package/dist/{numfmt-BBgB7iQA.js → dos-time-dD0z1YWU.js} +2 -177
  21. package/dist/format.cjs +1264 -0
  22. package/dist/format.d.cts +59 -0
  23. package/dist/format.d.ts +59 -0
  24. package/dist/format.js +1262 -0
  25. package/dist/import.cjs +10 -0
  26. package/dist/import.d.cts +10 -0
  27. package/dist/import.d.ts +10 -0
  28. package/dist/import.js +1 -0
  29. package/dist/index.cjs +24 -607
  30. package/dist/index.d.cts +32 -6
  31. package/dist/index.d.ts +31 -5
  32. package/dist/index.js +10 -594
  33. package/dist/{warnings-C_12PT4t.d.cts → model-0JikLfuM.d.cts} +1 -41
  34. package/dist/{warnings-DXJKe1lx.d.ts → model-0JikLfuM.d.ts} +1 -41
  35. package/dist/numfmt-BmEbm78Y.cjs +125 -0
  36. package/dist/numfmt-DCDrX9P1.js +114 -0
  37. package/dist/pipeline-BAJtzBdW.js +1085 -0
  38. package/dist/pipeline-Bnf7EU3X.cjs +1132 -0
  39. package/dist/pipeline-CctEa86r.d.cts +186 -0
  40. package/dist/pipeline-I8SLmV9S.d.ts +186 -0
  41. package/dist/{read-Ym1voUct.cjs → read-CZEWV4rK.cjs} +181 -17
  42. package/dist/{read-DDN5ZsPe.js → read-LWti17lz.js} +169 -5
  43. package/dist/read.cjs +1 -1
  44. package/dist/read.d.cts +78 -4
  45. package/dist/read.d.ts +78 -4
  46. package/dist/read.js +1 -1
  47. package/dist/render.cjs +751 -0
  48. package/dist/render.d.cts +215 -0
  49. package/dist/render.d.ts +215 -0
  50. package/dist/render.js +732 -0
  51. package/dist/{sheet-names-uT2EH5Ui.js → sheet-names-7p-joVsG.js} +2 -101
  52. package/dist/{sheet-names-qpXsvMpM.cjs → sheet-names-B8U5RAW0.cjs} +14 -167
  53. package/dist/warnings-B1v58nCZ.d.cts +41 -0
  54. package/dist/warnings-B1v58nCZ.d.ts +41 -0
  55. package/dist/worker.cjs +10 -2
  56. package/dist/worker.d.cts +10 -4
  57. package/dist/worker.d.ts +10 -4
  58. package/dist/worker.js +10 -2
  59. package/dist/{write-CYpLGuzl.d.ts → write-DM6ieuQY.d.ts} +2 -1
  60. package/dist/{write-DubvcG-x.js → write-DjgWy1PK.js} +5 -2
  61. package/dist/{write-C5JgeIar.d.cts → write-DtjfdIFm.d.cts} +2 -1
  62. package/dist/{write-BOh9jfu1.cjs → write-f9kcYf5K.cjs} +31 -28
  63. package/package.json +32 -1
  64. package/dist/read-C6L7Nyy3.d.cts +0 -78
  65. package/dist/read-Ddkks7qC.d.ts +0 -78
@@ -1,6 +1,9 @@
1
1
  const require_errors = require("./errors-DOPrrGS4.cjs");
2
- const require_numfmt = require("./numfmt-Dv6AjopS.cjs");
3
- const require_sheet_names = require("./sheet-names-qpXsvMpM.cjs");
2
+ const require_dos_time = require("./dos-time-FZ7-1tot.cjs");
3
+ const require_sheet_names = require("./sheet-names-B8U5RAW0.cjs");
4
+ const require_address = require("./address-DZBHchLv.cjs");
5
+ const require_dates = require("./dates-CA1dCizp.cjs");
6
+ const require_cells = require("./cells-CPXU722t.cjs");
4
7
  const SIG_LOCAL = 67324752;
5
8
  const SIG_CENTRAL = 33639248;
6
9
  const SIG_EOCD = 101010256;
@@ -14,25 +17,25 @@ function isAscii(s) {
14
17
  return true;
15
18
  }
16
19
  function toChunks(data) {
17
- if (typeof data === "string") return [require_numfmt.encodeUtf8(data)];
20
+ if (typeof data === "string") return [require_dos_time.encodeUtf8(data)];
18
21
  if (data instanceof Uint8Array) return [data];
19
22
  return data;
20
23
  }
21
24
  /** Writes the entries, in order, into one zip archive. */
22
25
  async function writeZip(entries, options = {}) {
23
- const codec = options.codec ?? require_numfmt.nativeCodec;
26
+ const codec = options.codec ?? require_dos_time.nativeCodec;
24
27
  const defaultModified = options.modified ?? /* @__PURE__ */ new Date();
25
28
  const seen = /* @__PURE__ */ new Set();
26
29
  const written = [];
27
30
  let offset = 0;
28
31
  for await (const entry of entries) {
29
- require_numfmt.throwIfAborted(options.signal);
32
+ require_dos_time.throwIfAborted(options.signal);
30
33
  const { name } = entry;
31
34
  if (name.length === 0 || name.startsWith("/") || name.includes("\0") || name.includes("\\")) throw new Error(`Invalid zip entry name: ${JSON.stringify(name)}`);
32
35
  if (seen.has(name)) throw new Error(`Duplicate zip entry name: ${name}`);
33
36
  seen.add(name);
34
37
  if (written.length >= MAX_ENTRIES) throw zip64Required("more than 65,534 entries");
35
- const nameBytes = require_numfmt.encodeUtf8(name);
38
+ const nameBytes = require_dos_time.encodeUtf8(name);
36
39
  if (nameBytes.length > 65535) throw new Error(`Zip entry name too long: ${name.slice(0, 40)}...`);
37
40
  let size = 0;
38
41
  let crc = 0;
@@ -41,7 +44,7 @@ async function writeZip(entries, options = {}) {
41
44
  for await (const chunk of src) {
42
45
  size += chunk.length;
43
46
  if (size > 4294967294) throw zip64Required(`entry ${name} over 4 GiB`);
44
- crc = require_numfmt.crc32(chunk, crc);
47
+ crc = require_dos_time.crc32(chunk, crc);
45
48
  if (kept) {
46
49
  if (size <= 65536) kept.push(chunk);
47
50
  else kept = void 0;
@@ -56,18 +59,18 @@ async function writeZip(entries, options = {}) {
56
59
  const parts = [];
57
60
  for await (const chunk of tap(toChunks(entry.data))) parts.push(chunk);
58
61
  method = 0;
59
- data = require_numfmt.concatBytes(parts);
62
+ data = require_dos_time.concatBytes(parts);
60
63
  } else {
61
64
  const deflated = await codec.deflateRaw(tap(toChunks(entry.data)), options.signal);
62
65
  if (kept && deflated.length >= size) {
63
66
  method = 0;
64
- data = require_numfmt.concatBytes(kept);
67
+ data = require_dos_time.concatBytes(kept);
65
68
  } else {
66
69
  method = 8;
67
70
  data = deflated;
68
71
  }
69
72
  }
70
- const { time, date } = require_numfmt.toDosDateTime(entry.modified ?? defaultModified);
73
+ const { time, date } = require_dos_time.toDosDateTime(entry.modified ?? defaultModified);
71
74
  const flags = isAscii(name) ? 0 : FLAG_UTF8;
72
75
  written.push({
73
76
  nameBytes,
@@ -85,7 +88,7 @@ async function writeZip(entries, options = {}) {
85
88
  }
86
89
  const parts = [];
87
90
  for (const w of written) {
88
- const h = new require_numfmt.ByteWriter(30 + w.nameBytes.length);
91
+ const h = new require_dos_time.ByteWriter(30 + w.nameBytes.length);
89
92
  h.u32(SIG_LOCAL);
90
93
  h.u16(w.method === 8 ? 20 : 10);
91
94
  h.u16(w.flags);
@@ -103,7 +106,7 @@ async function writeZip(entries, options = {}) {
103
106
  const cdOffset = offset;
104
107
  let cdSize = 0;
105
108
  for (const w of written) {
106
- const c = new require_numfmt.ByteWriter(46 + w.nameBytes.length);
109
+ const c = new require_dos_time.ByteWriter(46 + w.nameBytes.length);
107
110
  c.u32(SIG_CENTRAL);
108
111
  c.u16(20);
109
112
  c.u16(w.method === 8 ? 20 : 10);
@@ -126,7 +129,7 @@ async function writeZip(entries, options = {}) {
126
129
  cdSize += c.bytes.length;
127
130
  }
128
131
  if (cdOffset + cdSize > 4294967294) throw zip64Required("archive over 4 GiB");
129
- const e = new require_numfmt.ByteWriter(22);
132
+ const e = new require_dos_time.ByteWriter(22);
130
133
  e.u32(SIG_EOCD);
131
134
  e.u16(0);
132
135
  e.u16(0);
@@ -136,7 +139,7 @@ async function writeZip(entries, options = {}) {
136
139
  e.u32(cdOffset);
137
140
  e.u16(0);
138
141
  parts.push(e.bytes);
139
- return require_numfmt.concatBytes(parts);
142
+ return require_dos_time.concatBytes(parts);
140
143
  }
141
144
  // src/internal/write/parts.ts
142
145
  /**
@@ -979,11 +982,11 @@ var SharedStrings = class {
979
982
  for (const item of this.items) {
980
983
  buf += item;
981
984
  if (buf.length >= CHUNK_CHARS) {
982
- yield require_numfmt.encodeUtf8(buf);
985
+ yield require_dos_time.encodeUtf8(buf);
983
986
  buf = "";
984
987
  }
985
988
  }
986
- yield require_numfmt.encodeUtf8(`${buf}</sst>`);
989
+ yield require_dos_time.encodeUtf8(`${buf}</sst>`);
987
990
  }
988
991
  };
989
992
  function textElement(s) {
@@ -1047,12 +1050,12 @@ function planSheet(sheet, index, tabSelected, styles, schemes) {
1047
1050
  col: c
1048
1051
  } });
1049
1052
  used = true;
1050
- if (measuring) features.measure(c, require_sheet_names.cellText(cell));
1053
+ if (measuring) features.measure(c, require_cells.cellText(cell));
1051
1054
  if (c < plan.minCol) plan.minCol = c;
1052
1055
  if (c > plan.maxCol) plan.maxCol = c;
1053
1056
  }
1054
1057
  if (used) {
1055
- if (r >= 1048576) throw new require_errors.ValidationError("OUT_OF_BOUNDS", `Sheet ${sheet.name}: row ${r + 1} is beyond row ${require_sheet_names.MAX_ROWS}.`, { details: {
1058
+ if (r >= 1048576) throw new require_errors.ValidationError("OUT_OF_BOUNDS", `Sheet ${sheet.name}: row ${r + 1} is beyond row ${require_address.MAX_ROWS}.`, { details: {
1056
1059
  sheet: sheet.name,
1057
1060
  row: r
1058
1061
  } });
@@ -1075,10 +1078,10 @@ function rowSpan(plan) {
1075
1078
  async function* sheetXml(plan, ctx, onRow) {
1076
1079
  const { sheet, features, links } = plan;
1077
1080
  const name = sheet.name;
1078
- const dimension = plan.maxRow < 0 ? "A1" : plan.minRow === plan.maxRow && plan.minCol === plan.maxCol ? `${require_sheet_names.encodeCol(plan.minCol)}${plan.minRow + 1}` : `${require_sheet_names.encodeCol(plan.minCol)}${plan.minRow + 1}:${require_sheet_names.encodeCol(plan.maxCol)}${plan.maxRow + 1}`;
1081
+ const dimension = plan.maxRow < 0 ? "A1" : plan.minRow === plan.maxRow && plan.minCol === plan.maxCol ? `${require_address.encodeCol(plan.minCol)}${plan.minRow + 1}` : `${require_address.encodeCol(plan.minCol)}${plan.minRow + 1}:${require_address.encodeCol(plan.maxCol)}${plan.maxRow + 1}`;
1079
1082
  let buf = `${require_sheet_names.XML_DECL}<worksheet xmlns="${NS_MAIN}" xmlns:r="${NS_REL}">` + features.sheetPrXml + `<dimension ref="${dimension}"/>` + features.sheetViewsXml + features.sheetFormatPrXml + features.colsXml() + "<sheetData>";
1080
1083
  const colLetters = [];
1081
- const letters = (c) => colLetters[c] ??= require_sheet_names.encodeCol(c);
1084
+ const letters = (c) => colLetters[c] ??= require_address.encodeCol(c);
1082
1085
  const rows = sheet.rows;
1083
1086
  const defaultStyle = sheet.defaultStyle;
1084
1087
  const colProps = sheet.colProps;
@@ -1107,13 +1110,13 @@ async function* sheetXml(plan, ctx, onRow) {
1107
1110
  buf += rowXml ? `<row r="${rowNum}"${attrs}>${rowXml}</row>` : `<row r="${rowNum}"${attrs}/>`;
1108
1111
  if (rowXml) onRow();
1109
1112
  if (buf.length >= CHUNK_CHARS) {
1110
- yield require_numfmt.encodeUtf8(buf);
1113
+ yield require_dos_time.encodeUtf8(buf);
1111
1114
  buf = "";
1112
1115
  }
1113
1116
  }
1114
1117
  }
1115
1118
  buf += `</sheetData>${features.afterDataXml(links)}</worksheet>`;
1116
- yield require_numfmt.encodeUtf8(buf);
1119
+ yield require_dos_time.encodeUtf8(buf);
1117
1120
  }
1118
1121
  /** One <c> element. */
1119
1122
  function cellXml(input, ref, sheet, ctx, layers) {
@@ -1140,7 +1143,7 @@ function cellXml(input, ref, sheet, ctx, layers) {
1140
1143
  let f;
1141
1144
  if (cell.arrayRef !== void 0) {
1142
1145
  try {
1143
- require_sheet_names.decodeRange(cell.arrayRef);
1146
+ require_address.decodeRange(cell.arrayRef);
1144
1147
  } catch {
1145
1148
  throw cellError("INVALID_REF", `arrayRef ${JSON.stringify(cell.arrayRef)} is not an A1 range`, sheet, ref);
1146
1149
  }
@@ -1186,7 +1189,7 @@ function scalar(value, vtype, sheet, ref, ctx, isFormula) {
1186
1189
  case "date": {
1187
1190
  let serial;
1188
1191
  try {
1189
- serial = require_numfmt.dateToSerial(value, {
1192
+ serial = require_dates.dateToSerial(value, {
1190
1193
  date1904: ctx.date1904,
1191
1194
  dateZone: ctx.dateZone
1192
1195
  });
@@ -1296,8 +1299,8 @@ function planWorkbook(wb, styles, schemes) {
1296
1299
  /** Writes a workbook as .xlsx bytes. */
1297
1300
  async function toUint8Array(wb, options = {}) {
1298
1301
  const { signal } = options;
1299
- const onProgress = require_numfmt.throttleProgress(options.onProgress);
1300
- require_numfmt.throwIfAborted(signal);
1302
+ const onProgress = require_dos_time.throttleProgress(options.onProgress);
1303
+ require_dos_time.throwIfAborted(signal);
1301
1304
  onProgress?.({
1302
1305
  phase: "prepare",
1303
1306
  ratio: 0
@@ -1391,7 +1394,7 @@ async function toUint8Array(wb, options = {}) {
1391
1394
  name: `xl/worksheets/sheet${i + 1}.xml`,
1392
1395
  data: (async function* () {
1393
1396
  for await (const chunk of chunks) {
1394
- require_numfmt.throwIfAborted(signal);
1397
+ require_dos_time.throwIfAborted(signal);
1395
1398
  yield chunk;
1396
1399
  }
1397
1400
  })()
@@ -1412,7 +1415,7 @@ async function toUint8Array(wb, options = {}) {
1412
1415
  name: "xl/sharedStrings.xml",
1413
1416
  data: (async function* () {
1414
1417
  for (const chunk of strings.chunks()) {
1415
- require_numfmt.throwIfAborted(signal);
1418
+ require_dos_time.throwIfAborted(signal);
1416
1419
  yield chunk;
1417
1420
  }
1418
1421
  })()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javascript-excel",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.3",
4
4
  "private": false,
5
5
  "description": "Read and write .xlsx and .csv files in browsers, Web Workers and Node. 2.0 is a from-scratch rewrite in progress.",
6
6
  "keywords": [
@@ -83,6 +83,36 @@
83
83
  "default": "./dist/worker.cjs"
84
84
  }
85
85
  },
86
+ "./render": {
87
+ "import": {
88
+ "types": "./dist/render.d.ts",
89
+ "default": "./dist/render.js"
90
+ },
91
+ "require": {
92
+ "types": "./dist/render.d.cts",
93
+ "default": "./dist/render.cjs"
94
+ }
95
+ },
96
+ "./format": {
97
+ "import": {
98
+ "types": "./dist/format.d.ts",
99
+ "default": "./dist/format.js"
100
+ },
101
+ "require": {
102
+ "types": "./dist/format.d.cts",
103
+ "default": "./dist/format.cjs"
104
+ }
105
+ },
106
+ "./import": {
107
+ "import": {
108
+ "types": "./dist/import.d.ts",
109
+ "default": "./dist/import.js"
110
+ },
111
+ "require": {
112
+ "types": "./dist/import.d.cts",
113
+ "default": "./dist/import.cjs"
114
+ }
115
+ },
86
116
  "./package.json": "./package.json"
87
117
  },
88
118
  "engines": {
@@ -98,6 +128,7 @@
98
128
  "test:browser": "vitest run --config vitest.browser.config.ts",
99
129
  "bench": "node --expose-gc bench/run.mjs",
100
130
  "bench:worker": "node --expose-gc bench/worker.mjs",
131
+ "bench:render": "node --expose-gc bench/render.mjs",
101
132
  "conformance:artifact": "node scripts/conformance.mjs artifact",
102
133
  "conformance:doc": "node scripts/conformance.mjs doc"
103
134
  },
@@ -1,78 +0,0 @@
1
- import { I as Workbook, r as BinaryInput, t as ExcelWarning, u as Cell } from "./warnings-C_12PT4t.cjs";
2
- import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
3
- import { t as Progress } from "./write-C5JgeIar.cjs";
4
- /**
5
- * Format detection tables for the reader (docs/api.md §5.2). Internal.
6
- *
7
- * Detection is data: container signatures first, then, for OPC packages, the
8
- * workbook part's content type. Supporting another format later (.xlsb, .xls)
9
- * is one more row plus a decoder; the reader dispatches on `decoder`.
10
- */
11
- /** Every format `detectFormat` can name. */
12
- type FormatName = "xlsx" | "xlsm" | "xltx" | "xltm" | "xlsb" | "ods" | "cfb" | "zip" | "unknown";
13
- /** Result of `read`. */
14
- interface ReadResult {
15
- workbook: Workbook<Cell>;
16
- warnings: ExcelWarning[];
17
- }
18
- /** Options for `read`. */
19
- interface ReadOptions {
20
- /** Only parse these sheets (by name or index); the others are listed with empty rows. Default: all. */
21
- sheets?: Array<string | number> | undefined;
22
- /** Parse styles (default true). false is faster: no `cell.style`, but date detection still uses the number format. */
23
- styles?: boolean | undefined;
24
- /** Return formula text (default true). false: cached values only. */
25
- formulas?: boolean | undefined;
26
- /** `'date'` (default): date-formatted numbers become `Date`. `'serial'`: leave them as numbers. */
27
- dates?: "date" | "serial" | undefined;
28
- /** Default `'local'`. */
29
- dateZone?: "local" | "utc" | undefined;
30
- /** Rich text as runs (default) or flattened to a plain string. */
31
- richText?: "runs" | "plain" | undefined;
32
- limits?: Partial<ReadLimits> | undefined;
33
- /** Rejects with `signal.reason` when aborted. */
34
- signal?: AbortSignalLike | undefined;
35
- onProgress?: ((p: Progress) => void) | undefined;
36
- /** Called as warnings occur, in addition to `ReadResult.warnings`. */
37
- onWarning?: ((w: ExcelWarning) => void) | undefined;
38
- }
39
- /** Limits for untrusted input. Exceeding one throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit` names it). */
40
- interface ReadLimits {
41
- maxInputBytes: number;
42
- maxEntries: number;
43
- /** Decompressed bytes of one part. */
44
- maxEntryBytes: number;
45
- /** Decompressed bytes of all parts read. */
46
- maxTotalBytes: number;
47
- /** Decompressed / compressed, per entry, checked once an entry has produced more than 1 MiB. */
48
- maxRatio: number;
49
- maxXmlDepth: number;
50
- /** All sheets together. */
51
- maxCells: number;
52
- maxSharedStrings: number;
53
- /** Then a single `WARNINGS_TRUNCATED`. */
54
- maxWarnings: number;
55
- }
56
- /** Default limits (docs/api.md §5.2; the measurements behind each value are listed there). */
57
- declare const DEFAULT_READ_LIMITS: Readonly<ReadLimits>;
58
- /** A sheet as listed by `readSheetNames`. */
59
- interface SheetInfo {
60
- name: string;
61
- index: number;
62
- state: "visible" | "hidden" | "veryHidden";
63
- }
64
- /**
65
- * What `detectFormat` recognises. `'cfb'` is a legacy `.xls` or an encrypted OOXML file.
66
- * `read` reads xlsx, xlsm, xltx and xltm; the others are rejected with UNSUPPORTED_FORMAT.
67
- */
68
- type DetectedFormat = FormatName;
69
- /** Detects the file format from the bytes. Never throws for unreadable input; returns `'unknown'` or `'zip'` instead. */
70
- declare function detectFormat(input: BinaryInput): Promise<DetectedFormat>;
71
- /** Lists the worksheets (name, index, visibility) without parsing any sheet. */
72
- declare function readSheetNames(input: BinaryInput, options?: {
73
- limits?: Partial<ReadLimits> | undefined;
74
- signal?: AbortSignalLike | undefined;
75
- }): Promise<SheetInfo[]>;
76
- /** Reads an .xlsx, .xlsm, .xltx or .xltm file into the model. */
77
- declare function read(input: BinaryInput, options?: ReadOptions): Promise<ReadResult>;
78
- export { ReadResult as a, read as c, ReadOptions as i, readSheetNames as l, DetectedFormat as n, SheetInfo as o, ReadLimits as r, detectFormat as s, DEFAULT_READ_LIMITS as t };
@@ -1,78 +0,0 @@
1
- import { N as Workbook, P as BinaryInput, s as Cell, t as ExcelWarning } from "./warnings-DXJKe1lx.js";
2
- import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
3
- import { t as Progress } from "./write-CYpLGuzl.js";
4
- /**
5
- * Format detection tables for the reader (docs/api.md §5.2). Internal.
6
- *
7
- * Detection is data: container signatures first, then, for OPC packages, the
8
- * workbook part's content type. Supporting another format later (.xlsb, .xls)
9
- * is one more row plus a decoder; the reader dispatches on `decoder`.
10
- */
11
- /** Every format `detectFormat` can name. */
12
- type FormatName = "xlsx" | "xlsm" | "xltx" | "xltm" | "xlsb" | "ods" | "cfb" | "zip" | "unknown";
13
- /** Result of `read`. */
14
- interface ReadResult {
15
- workbook: Workbook<Cell>;
16
- warnings: ExcelWarning[];
17
- }
18
- /** Options for `read`. */
19
- interface ReadOptions {
20
- /** Only parse these sheets (by name or index); the others are listed with empty rows. Default: all. */
21
- sheets?: Array<string | number> | undefined;
22
- /** Parse styles (default true). false is faster: no `cell.style`, but date detection still uses the number format. */
23
- styles?: boolean | undefined;
24
- /** Return formula text (default true). false: cached values only. */
25
- formulas?: boolean | undefined;
26
- /** `'date'` (default): date-formatted numbers become `Date`. `'serial'`: leave them as numbers. */
27
- dates?: "date" | "serial" | undefined;
28
- /** Default `'local'`. */
29
- dateZone?: "local" | "utc" | undefined;
30
- /** Rich text as runs (default) or flattened to a plain string. */
31
- richText?: "runs" | "plain" | undefined;
32
- limits?: Partial<ReadLimits> | undefined;
33
- /** Rejects with `signal.reason` when aborted. */
34
- signal?: AbortSignalLike | undefined;
35
- onProgress?: ((p: Progress) => void) | undefined;
36
- /** Called as warnings occur, in addition to `ReadResult.warnings`. */
37
- onWarning?: ((w: ExcelWarning) => void) | undefined;
38
- }
39
- /** Limits for untrusted input. Exceeding one throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit` names it). */
40
- interface ReadLimits {
41
- maxInputBytes: number;
42
- maxEntries: number;
43
- /** Decompressed bytes of one part. */
44
- maxEntryBytes: number;
45
- /** Decompressed bytes of all parts read. */
46
- maxTotalBytes: number;
47
- /** Decompressed / compressed, per entry, checked once an entry has produced more than 1 MiB. */
48
- maxRatio: number;
49
- maxXmlDepth: number;
50
- /** All sheets together. */
51
- maxCells: number;
52
- maxSharedStrings: number;
53
- /** Then a single `WARNINGS_TRUNCATED`. */
54
- maxWarnings: number;
55
- }
56
- /** Default limits (docs/api.md §5.2; the measurements behind each value are listed there). */
57
- declare const DEFAULT_READ_LIMITS: Readonly<ReadLimits>;
58
- /** A sheet as listed by `readSheetNames`. */
59
- interface SheetInfo {
60
- name: string;
61
- index: number;
62
- state: "visible" | "hidden" | "veryHidden";
63
- }
64
- /**
65
- * What `detectFormat` recognises. `'cfb'` is a legacy `.xls` or an encrypted OOXML file.
66
- * `read` reads xlsx, xlsm, xltx and xltm; the others are rejected with UNSUPPORTED_FORMAT.
67
- */
68
- type DetectedFormat = FormatName;
69
- /** Detects the file format from the bytes. Never throws for unreadable input; returns `'unknown'` or `'zip'` instead. */
70
- declare function detectFormat(input: BinaryInput): Promise<DetectedFormat>;
71
- /** Lists the worksheets (name, index, visibility) without parsing any sheet. */
72
- declare function readSheetNames(input: BinaryInput, options?: {
73
- limits?: Partial<ReadLimits> | undefined;
74
- signal?: AbortSignalLike | undefined;
75
- }): Promise<SheetInfo[]>;
76
- /** Reads an .xlsx, .xlsm, .xltx or .xltm file into the model. */
77
- declare function read(input: BinaryInput, options?: ReadOptions): Promise<ReadResult>;
78
- export { ReadResult as a, read as c, ReadOptions as i, readSheetNames as l, DetectedFormat as n, SheetInfo as o, ReadLimits as r, detectFormat as s, DEFAULT_READ_LIMITS as t };