@extend-ai/react-xlsx 0.11.0 → 0.12.1
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 +50 -2
- package/dist/duke_sheets_wasm_bg.wasm +0 -0
- package/dist/index.cjs +320 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +240 -2
- package/dist/index.d.ts +240 -2
- package/dist/index.js +320 -102
- package/dist/index.js.map +1 -1
- package/dist/xlsx-worker.js +1 -1
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -225,7 +225,7 @@ These hooks work inside `XlsxViewer` or `XlsxViewerProvider` context.
|
|
|
225
225
|
- `useXlsxViewer()` for full controller access
|
|
226
226
|
- `useXlsxViewerSelection()` for active cell and range state
|
|
227
227
|
- `useXlsxViewerZoom()` for zoom controls and limits
|
|
228
|
-
- `useXlsxViewerEditing()` for editing, undo/redo, fill, merge, clipboard, and export actions
|
|
228
|
+
- `useXlsxViewerEditing()` for editing, persisted style writes, undo/redo, fill, merge, clipboard, and export actions
|
|
229
229
|
- `useXlsxViewerTables()` for table metadata and table sorting
|
|
230
230
|
- `useXlsxViewerImages()` for embedded image and chart selection, movement, and resizing
|
|
231
231
|
- `useXlsxViewerCharts()` for chart and chartsheet state
|
|
@@ -414,7 +414,54 @@ Common rendering props:
|
|
|
414
414
|
- `renderTableHeaderMenu?: (props: XlsxTableHeaderMenuRenderProps) => React.ReactNode`
|
|
415
415
|
- `renderScroller?: (props: XlsxScrollerRenderProps) => React.ReactNode`
|
|
416
416
|
|
|
417
|
-
###
|
|
417
|
+
### Persisted Cell Styling
|
|
418
|
+
|
|
419
|
+
Use `setCellStyle`, `setSelectedCellStyle`, and `setRangeStyle` when a custom toolbar should write Excel formatting into the workbook. These APIs mutate workbook data, participate in undo/redo, refresh the viewer, and are included in `exportXlsx()`.
|
|
420
|
+
|
|
421
|
+
```tsx
|
|
422
|
+
import {
|
|
423
|
+
useXlsxViewer,
|
|
424
|
+
type XlsxCellStyleInput
|
|
425
|
+
} from "@extend-ai/react-xlsx";
|
|
426
|
+
|
|
427
|
+
const highlightStyle: XlsxCellStyleInput = {
|
|
428
|
+
font: { bold: true, color: { colorType: "rgb", hex: "1D4ED8" } },
|
|
429
|
+
fill: { fillType: "solid", color: { colorType: "rgb", hex: "DBEAFE" } },
|
|
430
|
+
alignment: { horizontal: "center", vertical: "center", wrapText: true }
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
function FormattingButton() {
|
|
434
|
+
const { selection, setRangeStyle, setSelectedCellStyle } = useXlsxViewer();
|
|
435
|
+
|
|
436
|
+
return (
|
|
437
|
+
<button
|
|
438
|
+
type="button"
|
|
439
|
+
onClick={() => {
|
|
440
|
+
if (selection) {
|
|
441
|
+
setRangeStyle(selection, highlightStyle);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
setSelectedCellStyle(highlightStyle);
|
|
445
|
+
}}
|
|
446
|
+
>
|
|
447
|
+
Highlight
|
|
448
|
+
</button>
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
`XlsxCellStyleInput` supports these persisted Excel style groups:
|
|
454
|
+
|
|
455
|
+
| Field | Type | Notes |
|
|
456
|
+
| --- | --- | --- |
|
|
457
|
+
| `font` | `XlsxCellFontStyleInput` | Font family, size, bold, italic, underline, strikethrough, color, superscript/subscript. |
|
|
458
|
+
| `fill` | `XlsxCellFillStyleInput` | Solid, pattern, and gradient fills. |
|
|
459
|
+
| `border` | `XlsxCellBorderStyleInput` | Per-edge borders, colors, styles, and diagonal borders. |
|
|
460
|
+
| `alignment` | `XlsxCellAlignmentInput` | Horizontal/vertical alignment, wrap text, shrink to fit, indent, rotation, reading order. |
|
|
461
|
+
| `numberFormat` | `XlsxCellNumberFormatInput` | General, builtin, or custom Excel number format strings. |
|
|
462
|
+
| `protection` | `XlsxCellProtectionInput` | Locked/hidden flags used when sheet protection is enabled. |
|
|
463
|
+
|
|
464
|
+
### Render-Only Cell Styling
|
|
418
465
|
|
|
419
466
|
`getCellStyle` is an escape hatch for styling individual cells without forking the workbook data. It is called for every rendered cell and returns a partial `React.CSSProperties` that merges on top of the viewer's resolved style. Return `undefined` (or `null`) to leave a cell untouched.
|
|
420
467
|
|
|
@@ -528,6 +575,7 @@ The package exports the main types you are likely to use for custom integrations
|
|
|
528
575
|
- `XlsxViewerThumbnails`
|
|
529
576
|
- `XlsxScrollerRenderProps`
|
|
530
577
|
- `XlsxCellStyleContext`
|
|
578
|
+
- `XlsxCellStyleInput`, `XlsxCellFontStyleInput`, `XlsxCellFillStyleInput`, `XlsxCellBorderStyleInput`
|
|
531
579
|
- `XlsxSheetThumbnail`
|
|
532
580
|
- `UseXlsxViewerThumbnailsOptions`
|
|
533
581
|
- `XlsxChart`, `XlsxChartSeries`, `XlsxChartAxis`, `XlsxChartsheet`
|
|
Binary file
|