xlsx-svelte-viewer 1.5.0 → 2.0.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 +98 -49
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -1,85 +1,134 @@
|
|
|
1
1
|
# xlsx-svelte-viewer
|
|
2
2
|
|
|
3
|
+
**The Excel editor for Svelte: open, edit, calculate and save `.xlsx` workbooks entirely in the browser.**
|
|
4
|
+
|
|
3
5
|
[](https://www.npmjs.com/package/xlsx-svelte-viewer)
|
|
4
6
|
[](https://github.com/ChristopherVR/ooxml/blob/main/viewers/xlsx/LICENSE)
|
|
5
|
-
[](https://christophervr.github.io/ooxml/xlsx/)
|
|
8
8
|
|
|
9
|
-
[Live demo](https://christophervr.github.io/ooxml/xlsx/demo/)
|
|
9
|
+
[Live demo](https://christophervr.github.io/ooxml/xlsx/demo-svelte/) · [Documentation](https://christophervr.github.io/ooxml/xlsx/) · [Changelog](https://github.com/ChristopherVR/ooxml/blob/main/viewers/xlsx/packages/svelte/CHANGELOG.md) · [Report a bug](https://github.com/ChristopherVR/ooxml/issues)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+

|
|
12
12
|
|
|
13
13
|
## Install
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm install xlsx-svelte-viewer
|
|
16
|
+
npm install xlsx-svelte-viewer svelte
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
The package bundles its editor UI and adapter. The core model and shared controls
|
|
22
|
-
are installed as regular registry dependencies and the model API is re-exported.
|
|
23
|
-
One viewer package is enough; no separate core install is required.
|
|
19
|
+
One install is enough. The package bundles the editor and its Svelte adapter, and brings the workbook model (`@christophervr/xlsx-core`, re-exported from this package), `ooxml-core` and `ooxml-ui` with it. The peer dependency is `svelte` 5.
|
|
24
20
|
|
|
25
21
|
## Quick start
|
|
26
22
|
|
|
27
23
|
```svelte
|
|
28
24
|
<script>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
import XlsxEditor from 'xlsx-svelte-viewer';
|
|
26
|
+
import { createWorkbook } from 'xlsx-svelte-viewer/runtime';
|
|
27
|
+
|
|
28
|
+
let workbook = $state.raw(createWorkbook());
|
|
32
29
|
</script>
|
|
33
|
-
|
|
30
|
+
|
|
31
|
+
<div style="height: 100vh">
|
|
32
|
+
<XlsxEditor {workbook} onworkbookchange={(next) => (workbook = next)} />
|
|
33
|
+
</div>
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
application: each registers the same editor custom element.
|
|
36
|
+
Give the editor a height: the grid fills its container and scrolls inside it. Use one Excel editor package per application, since each registers the same `<xlsx-editor>` element.
|
|
38
37
|
|
|
39
|
-
##
|
|
38
|
+
## Open and save files
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
| ---------- | ----------------------------------------------------------------------------------- |
|
|
43
|
-
| Editing | Shared grid, ribbon, formula bar, sheet tabs and workbook change events. |
|
|
44
|
-
| Files | XLSX, XLSM, XLTX, legacy XLS and CSV loading through core. |
|
|
45
|
-
| Model | `createWorkbook`, `loadWorkbook`, `saveXlsx` and core types from the package entry. |
|
|
46
|
-
| Frameworks | The same `<xlsx-editor>` UI behind six thin adapters. |
|
|
40
|
+
Pass `bytes` (with `fileName`) or a `src` URL to open a file, and use the handle to save:
|
|
47
41
|
|
|
48
|
-
|
|
42
|
+
```svelte
|
|
43
|
+
<script>
|
|
44
|
+
import XlsxEditor from 'xlsx-svelte-viewer';
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
with `load`, `save` and `destroy`. `ooxml-core` and `ooxml-ui` are regular
|
|
53
|
-
dependencies. Parsing, formulas, editing and grid calculations live in core.
|
|
46
|
+
let editor;
|
|
47
|
+
</script>
|
|
54
48
|
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
<button onclick={() => editor.download('Budget.xlsx')}>Download</button>
|
|
50
|
+
<div style="height: 600px">
|
|
51
|
+
<XlsxEditor
|
|
52
|
+
bind:this={editor}
|
|
53
|
+
src="/files/budget.xlsx"
|
|
54
|
+
fileName="Budget.xlsx"
|
|
55
|
+
ondirtychange={(dirty) => console.log('unsaved edits:', dirty)}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
```
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
The editor opens `.xlsx`, `.xlsm`, `.xltx`, password-protected workbooks, legacy `.xls` and `.csv`. `save()` resolves to an `.xlsx` Blob, `saveBytes('csv')` exports the active sheet, and `download()` saves and marks the workbook clean. For headless work, the package also exports the model API: `createWorkbook`, `loadWorkbook`, `saveWorkbook`, `detectWorkbookFormat` and the rest of `@christophervr/xlsx-core`.
|
|
61
|
+
|
|
62
|
+
## What you get
|
|
63
|
+
|
|
64
|
+
- **The Excel window.** Ribbon with Tell me, Name Box, formula bar, grid with frozen panes, sheet tabs, a status bar with sum, average and count, the File backstage, Find and Replace, and undo and redo.
|
|
65
|
+
- **A calculation engine.** More than 500 functions, dynamic arrays, `LET` and `LAMBDA`, automatic or manual calculation and iterative calculation. Each formula has a work budget, and a slow calculation on open runs in a worker, so a workbook cannot freeze the page.
|
|
66
|
+
- **Formatting.** Fonts, fills, borders, number formats, merged cells, tables, outline groups, data validation and conditional formatting with colour scales, data bars and icon sets.
|
|
67
|
+
- **Objects.** Charts drawn from live values and edited from the Chart Design tab and Format pane, SmartArt, shapes, pictures, sparklines, worksheet PivotTables and slicers, and form controls linked to cells.
|
|
68
|
+
- **Collaboration.** Optional real-time co-editing between tabs of one browser, or across machines through a y-websocket compatible server you run.
|
|
69
|
+
- **Five interface languages.** English, French, German, Spanish and Simplified Chinese through `locale`. Workbook content is never translated.
|
|
70
|
+
- **Keyboard and screen reader support.** F6 regions, Excel's shortcuts, a grid that reads as a table, and forced-colours support.
|
|
71
|
+
|
|
72
|
+
## Svelte notes
|
|
59
73
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
- The package root is the Svelte 5 component (default export). The plain-JavaScript half, with `createWorkbook`, `loadWorkbook`, `mountEditor` and the shared types, is `xlsx-svelte-viewer/runtime`.
|
|
75
|
+
- Callbacks are lower-case props: `onworkbookchange`, `onselectionchange`, `ondirtychange`, `onfilecommand` and the others in the [bindings guide](https://christophervr.github.io/ooxml/xlsx/bindings#callbacks-and-events).
|
|
76
|
+
- `bind:this` gives the component, whose exports are the [handle](#the-handle): `load`, `save`, `download` and the rest, plus live `element` and `dirty` properties.
|
|
77
|
+
- Hold the workbook in `$state.raw`: it is a large plain object, and deep reactivity adds nothing but cost.
|
|
64
78
|
|
|
65
|
-
##
|
|
79
|
+
## Configuration
|
|
66
80
|
|
|
67
|
-
[
|
|
68
|
-
|
|
81
|
+
Every binding takes the same settings (the [bindings guide](https://christophervr.github.io/ooxml/xlsx/bindings) has the full list):
|
|
82
|
+
|
|
83
|
+
| Setting | What it does |
|
|
84
|
+
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
85
|
+
| `workbook`, `bytes`, `src`, `fileName` | What to show: a model, file bytes or a URL, and the name used by the title bar, Save and Download. |
|
|
86
|
+
| `readOnly` | Opens in Viewing mode. |
|
|
87
|
+
| `locale` | `en`, `fr`, `de`, `es` or `zh-CN` (tags such as `de-DE` map to one). |
|
|
88
|
+
| `theme`, `themeColors` | `light`, `dark` or `auto`, and `--xve-*` token overrides. See [theming](https://christophervr.github.io/ooxml/xlsx/theming). |
|
|
89
|
+
| `showToolbar`, `showFormulaBar` | Show or hide the ribbon and the formula bar. |
|
|
90
|
+
| `hiddenActions`, `ribbonAddIns` | Hide ribbon commands by id, or add your own tabs after Excel's. |
|
|
91
|
+
| `customization` | Capabilities, hidden ribbon tabs (`ribbon.hiddenTabs`, including File), extra backstage pages and menu items. |
|
|
92
|
+
| `storage`, `fileProviders` | Send Save and Open to your own storage, and offer OneDrive or your own cloud places in File > Open. |
|
|
93
|
+
| `collaboration` | Join a shared room. See [collaboration](https://christophervr.github.io/ooxml/xlsx/collaboration). |
|
|
94
|
+
| `authorName`, `validateReplace` | The author of new comments, and whether Replace applies data validation. |
|
|
95
|
+
|
|
96
|
+
### The handle
|
|
97
|
+
|
|
98
|
+
The handle has `load(bytes, fileName?)`, `newWorkbook()`, `save()`, `saveBytes(format?)`, `download(fileName?)`, `markClean()`, `openCloudFile(file)`, `select(ref)`, `getSelection()`, `setActiveSheet(index)`, `share()`, and the `dirty` and `element` properties.
|
|
99
|
+
|
|
100
|
+
### Building blocks
|
|
101
|
+
|
|
102
|
+
To build your own interface around the grid, use `createViewerBuildingBlocks` from `xlsx-svelte-viewer/runtime` with the `SpreadsheetCanvas.svelte`, `Toolbar.svelte`, `FormulaBar.svelte` and `SheetTabs.svelte` components (each its own subpath, such as `xlsx-svelte-viewer/Toolbar.svelte`). No title bar, ribbon, backstage or dialog is mounted, and the surface is read-only until you pass `canEdit: true`. See the [building blocks guide](https://christophervr.github.io/ooxml/xlsx/building-blocks).
|
|
103
|
+
|
|
104
|
+
## Supported environments
|
|
105
|
+
|
|
106
|
+
- **Browsers:** the last two major versions of Chrome, Edge, Firefox and Safari, and Safari 16.4 at least ([browser support](https://github.com/ChristopherVR/ooxml/blob/main/docs/browser-support.md)).
|
|
107
|
+
- **Node.js:** 22.3 or newer for builds, tests and server rendering. The package imports without a DOM; the editor itself runs in the browser.
|
|
108
|
+
- **Workers:** a workbook that needs a long calculation on open is calculated in a module worker that bundlers pick up from `new Worker(new URL(..., import.meta.url))`. A Content Security Policy must allow `worker-src 'self'`; without workers the calculation runs on the page under the same time limit.
|
|
109
|
+
|
|
110
|
+
## Limitations
|
|
111
|
+
|
|
112
|
+
This is not Microsoft Excel. Content the model does not cover is kept through a save or reported, as the [preservation guarantee](https://christophervr.github.io/ooxml/xlsx/preservation) describes, and the [features page](https://christophervr.github.io/ooxml/xlsx/features) lists what is supported.
|
|
113
|
+
|
|
114
|
+
- `.xlsb` and `.ods` do not open. Legacy `.xls` workbooks are read and saved as `.xlsx`.
|
|
115
|
+
- Macros never run; a `.xlsm` keeps its VBA project on save.
|
|
116
|
+
- External links, Power Query, OLAP and external-source PivotTables are kept but never refreshed, and `WEBSERVICE` is not evaluated.
|
|
117
|
+
- A few functions are not implemented (`ASC`, `DBCS`, `JIS`, `PHONETIC`, `INFO`, `WEBSERVICE`) and show `#NAME?`.
|
|
118
|
+
- Ink and OLE objects show as placeholders. In a shared room, pictures, other drawings and page setup stay local.
|
|
69
119
|
|
|
70
120
|
## Privacy and network use
|
|
71
121
|
|
|
72
|
-
The
|
|
122
|
+
The editor makes no network request when it opens, renders, edits or saves a workbook. Linked pictures are not fetched, external workbook links and linked data are not refreshed, and fonts come from the device and the file. Fonts are downloaded only when the reader turns on the Trust Center option (off by default) or the host sets `googleFonts`, and then only public font family names are sent, never the workbook. Workers load from your own origin. Hyperlinks open only when the reader follows them. Collaboration talks only to the server you configure (without one it stays in the browser), and OneDrive only when you connect it. Preferences such as the font-download choice (`ooxml.xlsx.allowFontDownloads`) stay in the browser's localStorage. Nothing collects analytics or telemetry. See [PRIVACY.md](https://github.com/ChristopherVR/ooxml/blob/main/PRIVACY.md).
|
|
73
123
|
|
|
74
|
-
##
|
|
124
|
+
## Related packages
|
|
75
125
|
|
|
76
|
-
|
|
126
|
+
- Other frameworks: [React](https://www.npmjs.com/package/@christophervr/xlsx-react-viewer) (`@christophervr/xlsx-react-viewer`), [Vue](https://www.npmjs.com/package/xlsx-vue-viewer) (`xlsx-vue-viewer`), [Angular](https://www.npmjs.com/package/xlsx-angular-viewer) (`xlsx-angular-viewer`), [Solid](https://www.npmjs.com/package/xlsx-solid-viewer) (`xlsx-solid-viewer`), [Vanilla JS](https://www.npmjs.com/package/xlsx-vanilla-viewer) (`xlsx-vanilla-viewer`).
|
|
127
|
+
- [`@christophervr/xlsx-core`](https://www.npmjs.com/package/@christophervr/xlsx-core): the workbook model on its own, for servers and scripts.
|
|
128
|
+
- [`xlsx-viewer-mcp`](https://www.npmjs.com/package/xlsx-viewer-mcp): Excel tools for AI agents over MCP.
|
|
129
|
+
- [`ooxml-core`](https://www.npmjs.com/package/ooxml-core) and [`ooxml-ui`](https://www.npmjs.com/package/ooxml-ui): the engine and the shared editor elements underneath.
|
|
130
|
+
- The same approach for [Word](https://github.com/ChristopherVR/ooxml/tree/main/viewers/docx#readme), [PowerPoint](https://github.com/ChristopherVR/ooxml/tree/main/viewers/pptx#readme) and [Visio](https://github.com/ChristopherVR/ooxml/tree/main/viewers/visio#readme), or the whole [OOXML Office suite](https://github.com/ChristopherVR/ooxml#readme).
|
|
77
131
|
|
|
78
|
-
##
|
|
132
|
+
## License
|
|
79
133
|
|
|
80
|
-
|
|
81
|
-
sign-in. See the [Office package and integration reference](https://github.com/ChristopherVR/ooxml/blob/main/docs/onedrive-integration.md#excel-xlsx)
|
|
82
|
-
for this product's load/save API, native storage wiring, sharing permissions and conflict recovery.
|
|
83
|
-
The [testing guide](https://github.com/ChristopherVR/ooxml/blob/main/docs/onedrive-testing.md)
|
|
84
|
-
separates test-local transports from live Microsoft acceptance. No simulation service is shipped;
|
|
85
|
-
OneDrive storage does not provide Microsoft Office coauthoring or automatic document merging.
|
|
134
|
+
[Apache-2.0](https://github.com/ChristopherVR/ooxml/blob/main/viewers/xlsx/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xlsx-svelte-viewer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Svelte 5 component for the Excel spreadsheet editor. Self-contained: includes the editor, the formula engine and the legacy .xls reader.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"editor",
|
|
@@ -66,11 +66,14 @@
|
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@christophervr/xlsx-core": "^
|
|
70
|
-
"ooxml-core": "^
|
|
71
|
-
"ooxml-ui": "^
|
|
69
|
+
"@christophervr/xlsx-core": "^2.0.0",
|
|
70
|
+
"ooxml-core": "^2.0.0",
|
|
71
|
+
"ooxml-ui": "^2.0.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"svelte": "^5.0.0"
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=22.3"
|
|
75
78
|
}
|
|
76
79
|
}
|