javascript-excel 1.0.3 → 2.0.0-alpha.2

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 (58) hide show
  1. package/README.md +69 -2
  2. package/dist/auto-width-2oBzjeNG.d.cts +11 -0
  3. package/dist/auto-width-CT-BihTW.d.ts +10 -0
  4. package/dist/csv-DyVH9y7S.cjs +647 -0
  5. package/dist/csv-pXfaputs.js +618 -0
  6. package/dist/csv.cjs +7 -0
  7. package/dist/csv.d.cts +89 -0
  8. package/dist/csv.d.ts +89 -0
  9. package/dist/csv.js +1 -0
  10. package/dist/dom.cjs +440 -0
  11. package/dist/dom.d.cts +78 -0
  12. package/dist/dom.d.ts +78 -0
  13. package/dist/dom.js +437 -0
  14. package/dist/errors-CvGlfw0E.js +28 -0
  15. package/dist/errors-DOPrrGS4.cjs +69 -0
  16. package/dist/index.cjs +627 -0
  17. package/dist/index.d.cts +255 -0
  18. package/dist/index.d.ts +255 -0
  19. package/dist/index.js +597 -0
  20. package/dist/infer-BR-J9BZa.js +88 -0
  21. package/dist/infer-D9EC9vJ-.cjs +105 -0
  22. package/dist/iso-date-3TY1OlGd.cjs +57 -0
  23. package/dist/iso-date-CXnn-9mT.js +46 -0
  24. package/dist/numfmt-BBgB7iQA.js +429 -0
  25. package/dist/numfmt-Dv6AjopS.cjs +512 -0
  26. package/dist/read-C6L7Nyy3.d.cts +78 -0
  27. package/dist/read-DDN5ZsPe.js +2909 -0
  28. package/dist/read-Ddkks7qC.d.ts +78 -0
  29. package/dist/read-Ym1voUct.cjs +2932 -0
  30. package/dist/read.cjs +6 -0
  31. package/dist/read.d.cts +15 -0
  32. package/dist/read.d.ts +15 -0
  33. package/dist/read.js +1 -0
  34. package/dist/sheet-names-qpXsvMpM.cjs +1005 -0
  35. package/dist/sheet-names-uT2EH5Ui.js +832 -0
  36. package/dist/signal-Dz0ZYe6d.d.cts +13 -0
  37. package/dist/signal-Dz0ZYe6d.d.ts +13 -0
  38. package/dist/warnings-C_12PT4t.d.cts +410 -0
  39. package/dist/warnings-DXJKe1lx.d.ts +410 -0
  40. package/dist/worker.cjs +240 -0
  41. package/dist/worker.d.cts +65 -0
  42. package/dist/worker.d.ts +65 -0
  43. package/dist/worker.js +238 -0
  44. package/dist/write-BOh9jfu1.cjs +1487 -0
  45. package/dist/write-C5JgeIar.d.cts +29 -0
  46. package/dist/write-CYpLGuzl.d.ts +29 -0
  47. package/dist/write-DubvcG-x.js +1470 -0
  48. package/package.json +101 -51
  49. package/.babelrc +0 -10
  50. package/.circleci/config.yml +0 -39
  51. package/lib/index.d.ts +0 -1
  52. package/lib/index.js +0 -22
  53. package/lib/javascript-excel.js +0 -17703
  54. package/src/index.tsx +0 -11
  55. package/test/unit/sample.spec.js +0 -5
  56. package/tsconfig.json +0 -54
  57. package/webpack.config.js +0 -19
  58. /package/{LICENSE.md → LICENSE} +0 -0
package/README.md CHANGED
@@ -1,2 +1,69 @@
1
- # JavaScript-Excel
2
- A lightweight library to build excel with power of JavaScript
1
+ # javascript-excel
2
+
3
+ > **2.0 is a from-scratch rewrite and is in progress.** The prerelease builds sheets from `{ columns, data }` datasets (`fromDataset`, `fromDatasets`, and `toDataset` for the way back), writes complete `.xlsx` files (cells, styles and sheet features), reads `.xlsx` files (`javascript-excel/read`), parses and serializes CSV (`javascript-excel/csv`), turns HTML tables into sheets and downloads files (`javascript-excel/dom`), and runs big jobs in a Web Worker (`javascript-excel/worker`). The API may change before 2.0.0.
4
+ >
5
+ > The last 1.x release is `javascript-excel@1.0.3`. Keep using it until 2.0 is released.
6
+
7
+ ```ts
8
+ import { toUint8Array } from "javascript-excel";
9
+
10
+ const bytes = await toUint8Array({
11
+ sheets: [
12
+ {
13
+ name: "Report",
14
+ rows: [
15
+ [{ value: "Item", style: { font: { bold: true }, fill: "DDEBF7" } }, "Qty", "Price"],
16
+ ["Pens", 10, { value: 1.5, style: { numFmt: "#,##0.00" } }],
17
+ ["Total", { formula: "SUM(B2:B2)", value: 10 }, new Date()],
18
+ ],
19
+ },
20
+ ],
21
+ });
22
+ ```
23
+
24
+ `toBlob()` returns the same file as a `Blob` for browser downloads.
25
+
26
+ **Written today:** strings (shared or inline), numbers, booleans, dates (1900 and 1904 systems), error values, rich text, formulas with cached values, array formulas, styled empty cells. The full style model: fonts, all fill patterns and gradients, all border styles with a colour per side, alignment (rotation, indent, reading order), protection flags, and built-in and custom number formats. Styles are deduplicated. Sheet order, names, visibility, the active sheet, the default font and document properties are written too.
27
+
28
+ **Sheet features:** column widths (characters, pixels or `'auto'`) and column styles, row heights and row styles, hidden rows and columns, outline levels, merges, autofilter, freeze panes, right-to-left sheets, zoom and selection, tab colours, default sizes, hyperlinks (external URLs limited to `http`, `https` and `mailto` unless you allow more with `hyperlinkSchemes`; internal locations), defined names, and print setup (orientation, paper size, fit to page, scale, margins, print area and titles, headers and footers).
29
+
30
+ Every writable field of the model is written; nothing is dropped silently. (`theme`, `indexedColors` and `dimension` are filled in by the reader and ignored on write.) Input that cannot be written faithfully throws a typed `ValidationError`.
31
+
32
+ **Datasets** (`{ columns, data }`):
33
+
34
+ ```ts
35
+ import { fromDataset, toBlob } from "javascript-excel";
36
+
37
+ const sheet = fromDataset(
38
+ {
39
+ columns: [
40
+ { title: "Name", key: "name", width: "auto" },
41
+ { title: "Sales", children: [{ title: "Q1", path: "sales.q1", numFmt: "#,##0.00", total: "sum" }] },
42
+ ],
43
+ data: [{ name: "Ada", sales: { q1: 1200.5 } }],
44
+ },
45
+ { freezeHeader: true, autoFilter: true, totals: { label: "Total" } },
46
+ );
47
+ ```
48
+
49
+ `fromDataset` supports `key`, `path` and function accessors, header groups (merged header cells), conditional columns, per-column types, number formats and widths, and a totals row with `SUBTOTAL` formulas and cached values. `fromDatasets` stacks several datasets on one sheet, and `toDataset` reads a sheet back into `{ columns, data }`.
50
+
51
+ **HTML tables** (`javascript-excel/dom`):
52
+
53
+ ```ts
54
+ import { toBlob } from "javascript-excel";
55
+ import { download, fromTable } from "javascript-excel/dom";
56
+
57
+ const sheet = fromTable(document.querySelector("table")!, { styles: "computed", freezeHeader: true, autoWidth: true });
58
+ download(await toBlob({ sheets: [sheet] }), "report.xlsx");
59
+ ```
60
+
61
+ `fromTable` reads `<thead>`, `<tbody>` and `<tfoot>`. It turns `colspan`/`rowspan` into merges, understands `data-type`, `data-value` and `data-numfmt` hints, skips hidden and `data-export-ignore` rows, keeps links, and with `styles: "computed"` maps bold, italic, underline, colour, background and alignment. `download` saves bytes, Blobs or strings through a temporary link without any dependency. Importing the module is safe during server-side rendering.
62
+
63
+ Runs on Node.js 22+ and in browsers with `CompressionStream('deflate-raw')`. Types are tested with TypeScript 5.0–7, with `moduleResolution` set to `node16`, `nodenext` or `bundler`.
64
+
65
+ Source, status and issues: https://github.com/securedeveloper/javascript-excel
66
+
67
+ ## License
68
+
69
+ MIT
@@ -0,0 +1,11 @@
1
+ import "./warnings-C_12PT4t.cjs";
2
+ /** Bounds for estimated column widths, in characters. */
3
+ interface AutoWidthOptions {
4
+ /** Default 8.43 (Excel's default width). */
5
+ min?: number | undefined;
6
+ /** Default 60 (a readability choice, not a measurement); at most 255. */
7
+ max?: number | undefined;
8
+ /** Rows measured from the top; default all. */
9
+ sampleRows?: number | undefined;
10
+ }
11
+ export { AutoWidthOptions as t };
@@ -0,0 +1,10 @@
1
+ /** Bounds for estimated column widths, in characters. */
2
+ interface AutoWidthOptions {
3
+ /** Default 8.43 (Excel's default width). */
4
+ min?: number | undefined;
5
+ /** Default 60 (a readability choice, not a measurement); at most 255. */
6
+ max?: number | undefined;
7
+ /** Rows measured from the top; default all. */
8
+ sampleRows?: number | undefined;
9
+ }
10
+ export { AutoWidthOptions as t };