@betteroffice/xlsx-react 0.0.2 → 0.0.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.
- package/README.md +37 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
React chrome for the BetterOffice XLSX editor — wraps
|
|
4
4
|
[`@betteroffice/xlsx`](https://www.npmjs.com/package/@betteroffice/xlsx) in a
|
|
5
|
-
|
|
5
|
+
drop-in `<XlsxEditor>` component with selection, keyboard, and clipboard wired up.
|
|
6
6
|
|
|
7
7
|
> **Experimental (`0.0.x`).** The API is unstable and may change in any release.
|
|
8
8
|
|
|
@@ -12,4 +12,40 @@ bun add @betteroffice/xlsx-react @betteroffice/xlsx react react-dom
|
|
|
12
12
|
|
|
13
13
|
`react` and `react-dom` (18 or 19) are peer dependencies.
|
|
14
14
|
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { useState } from "react";
|
|
19
|
+
import { XlsxEditor } from "@betteroffice/xlsx-react";
|
|
20
|
+
|
|
21
|
+
export function App() {
|
|
22
|
+
const [file, setFile] = useState<Uint8Array>();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<input
|
|
27
|
+
type="file"
|
|
28
|
+
accept=".xlsx"
|
|
29
|
+
onChange={async (e) => {
|
|
30
|
+
const f = e.target.files?.[0];
|
|
31
|
+
if (f) setFile(new Uint8Array(await f.arrayBuffer()));
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
<XlsxEditor
|
|
35
|
+
file={file}
|
|
36
|
+
fileName="workbook.xlsx"
|
|
37
|
+
onSave={(bytes) => {
|
|
38
|
+
// edited .xlsx bytes; without onSave the save button downloads them
|
|
39
|
+
console.log(`saved ${bytes.length} bytes`);
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Props: `file` (a `Uint8Array` of `.xlsx` bytes — omit it to render an empty
|
|
48
|
+
frame), `fileName`, `onSave`, `onReady` (a handle for host/agent-driven edits),
|
|
49
|
+
and `className`.
|
|
50
|
+
|
|
15
51
|
Docs: https://betteroffice.dev · Apache-2.0.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betteroffice/xlsx-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "React chrome for the BetterOffice xlsx editor.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"typecheck": "tsc --noEmit -p ."
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@betteroffice/xlsx": "0.0.
|
|
25
|
+
"@betteroffice/xlsx": "0.0.3"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": "^18.0.0 || ^19.0.0",
|