@rosperitus/excelerate-reader 0.12.3 → 0.13.0

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.
package/README.md CHANGED
@@ -5,8 +5,8 @@ Gnumeric and SpreadsheetML 2003 - and read how their cells are painted. Rust
5
5
  compiled to WebAssembly, no native module to build and nothing to install
6
6
  alongside it.
7
7
 
8
- This is the reading half of [excelerate](https://www.npmjs.com/package/excelerate).
9
- The full package also writes files back out and carries a 443-function formula
8
+ This is the reading half of [excelerate](https://www.npmjs.com/package/@rosperitus/excelerate).
9
+ The full package also writes files back out and carries a 518-function formula
10
10
  engine; if you need either, use that one. Here they are not compiled in at all,
11
11
  which is the point: a reader that cannot write cannot be made to write, and the
12
12
  binary is the smaller for it.
@@ -109,6 +109,11 @@ for you - an indexed colour needs the palette of the file it came from, and a
109
109
  theme colour needs the workbook theme, which the reader keeps but does not
110
110
  interpret.
111
111
 
112
+ For a block of cells, `getRangeStyles(sheet, "A1:H40")` answers `{ styles,
113
+ grid }`: each distinct style once and a grid of indexes into them, which is
114
+ one crossing instead of a `cellStyle` per cell. `cellStyleAt` and
115
+ `getRangeStylesAt` take 1-based numbers instead of an address.
116
+
112
117
  ## Formulas
113
118
 
114
119
  A formula's **text** is here (`getFormula`), and so is the value the file was
@@ -127,6 +132,10 @@ package may unpack, which is what stops a zip bomb. It defaults to 512 MB; a
127
132
  real workbook can outgrow that - a 100 MB package unpacking to 560 MB is not
128
133
  unusual - so raise it when you know where the file came from.
129
134
 
135
+ A callback as the fourth argument hears about each sheet as it is read:
136
+ `{ stage, done, total, what, fraction }`, with `total` `null` until the
137
+ workbook part says how many sheets there are.
138
+
130
139
  ## What is not here
131
140
 
132
141
  Writing, in any format - including painting a cell, writing a note, a link or
package/excelerate.d.ts CHANGED
@@ -278,19 +278,13 @@ export class Book {
278
278
  * them. A path is `undefined` where the file does not name one.
279
279
  */
280
280
  externalBooks(): any[];
281
- /**
282
- * Reads an xlsx package from its bytes.
283
- */
284
- static fromXlsx(bytes: Uint8Array): Book;
285
281
  /**
286
282
  * The value at `address` on sheet `sheet`, as a JS number, string, boolean
287
283
  * or `null`. A formula cell gives its cached result, not its text.
288
284
  */
289
285
  get(sheet: number, address: string): CellValue;
290
286
  /**
291
- * The same by 1-based row and column, the numbers `ROW()` and `COLUMN()`
292
- * return: `getAt(0, 4, 2)` is `B4`. Saves formatting an address only to
293
- * parse it again.
287
+ * The same by 1-based row and column.
294
288
  */
295
289
  getAt(sheet: number, row: number, column: number): CellValue;
296
290
  /**
@@ -422,7 +416,7 @@ export class Book {
422
416
  * Writes a value: a number, boolean, or string. A string starting with `=`
423
417
  * becomes a formula.
424
418
  */
425
- set(index: number, address: string, value: CellValue): void;
419
+ set(sheet: number, address: string, value: CellValue): void;
426
420
  /**
427
421
  * Sets that tab.
428
422
  */
package/excelerate.js CHANGED
@@ -304,20 +304,6 @@ class Book {
304
304
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
305
305
  return v1;
306
306
  }
307
- /**
308
- * Reads an xlsx package from its bytes.
309
- * @param {Uint8Array} bytes
310
- * @returns {Book}
311
- */
312
- static fromXlsx(bytes) {
313
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
314
- const len0 = WASM_VECTOR_LEN;
315
- const ret = wasm.book_fromXlsx(ptr0, len0);
316
- if (ret[2]) {
317
- throw takeFromExternrefTable0(ret[1]);
318
- }
319
- return Book.__wrap(ret[0]);
320
- }
321
307
  /**
322
308
  * The value at `address` on sheet `sheet`, as a JS number, string, boolean
323
309
  * or `null`. A formula cell gives its cached result, not its text.
@@ -335,9 +321,7 @@ class Book {
335
321
  return takeFromExternrefTable0(ret[0]);
336
322
  }
337
323
  /**
338
- * The same by 1-based row and column, the numbers `ROW()` and `COLUMN()`
339
- * return: `getAt(0, 4, 2)` is `B4`. Saves formatting an address only to
340
- * parse it again.
324
+ * The same by 1-based row and column.
341
325
  * @param {number} sheet
342
326
  * @param {number} row
343
327
  * @param {number} column
@@ -722,14 +706,14 @@ class Book {
722
706
  /**
723
707
  * Writes a value: a number, boolean, or string. A string starting with `=`
724
708
  * becomes a formula.
725
- * @param {number} index
709
+ * @param {number} sheet
726
710
  * @param {string} address
727
711
  * @param {CellValue} value
728
712
  */
729
- set(index, address, value) {
713
+ set(sheet, address, value) {
730
714
  const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
731
715
  const len0 = WASM_VECTOR_LEN;
732
- const ret = wasm.book_set(this.__wbg_ptr, index, ptr0, len0, value);
716
+ const ret = wasm.book_set(this.__wbg_ptr, sheet, ptr0, len0, value);
733
717
  if (ret[1]) {
734
718
  throw takeFromExternrefTable0(ret[0]);
735
719
  }
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rosperitus/excelerate-reader",
3
3
  "description": "Read spreadsheets in the browser or Node: xlsx, xls, ods, csv, html, SYLK, Gnumeric and SpreadsheetML, with cell styles. Reading only.",
4
- "version": "0.12.3",
4
+ "version": "0.13.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",