@extend-ai/react-xlsx 0.16.6 → 0.17.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 +56 -0
- package/dist/index.cjs +438 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +437 -99
- package/dist/index.js.map +1 -1
- package/dist/xlsx-worker.js +45 -20
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -344,6 +344,58 @@ Notes:
|
|
|
344
344
|
- Thumbnails preserve worksheet aspect ratio and paint into your supplied `<canvas>`.
|
|
345
345
|
- The current implementation renders a bounded top-left worksheet preview, including loaded embedded worksheet images, shapes, and form controls, but does not include charts.
|
|
346
346
|
|
|
347
|
+
## Range Highlighting
|
|
348
|
+
|
|
349
|
+
Pass an A1 reference or an array of references to `highlightedRanges` to draw blue bounding boxes with a thin border matching the selection outline and a subtle fill. The highlights are separate from the current selection and do not change workbook formatting. It works in both canvas and DOM rendering, including frozen panes, hidden rows/columns, merged cells, and zoom.
|
|
350
|
+
|
|
351
|
+
```tsx
|
|
352
|
+
<XlsxViewer
|
|
353
|
+
file={file}
|
|
354
|
+
highlightedRanges={["'Sheet 1'!$B$3:$E$8", "'Sheet 1'!G3:J8", "'Sheet 2'!B10:D14"]}
|
|
355
|
+
autoScrollToHighlightedRanges={true}
|
|
356
|
+
highlightClassName="my-range-highlight"
|
|
357
|
+
/>
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
`autoScrollToHighlightedRanges` defaults to `true`: a new set of ranges reveals the first range and switches to its worksheet. Other ranges remain highlighted on their respective sheets. Set it to `false` to leave both the current scroll position and active sheet unchanged. Navigation happens once per set of ranges or auto-scroll option change, so manual scrolling remains free afterward. A range larger than the viewport reveals its top-left portion; whole-row and whole-column references scroll only the relevant axis.
|
|
361
|
+
|
|
362
|
+
Set `highlightedRanges={null}` or `highlightedRanges={[]}` to clear all highlights. Omit the prop to manage highlighting through the controller instead. If any prop reference is invalid or unresolved, the previous highlights are cleared. Equivalent arrays do not repeat navigation on parent re-renders. An unqualified reference is bound to the active worksheet when applied, and stays on that worksheet when the user switches tabs.
|
|
363
|
+
|
|
364
|
+
### Controller API
|
|
365
|
+
|
|
366
|
+
The same API is available through `useXlsxViewer()` and `useXlsxViewerController()`:
|
|
367
|
+
|
|
368
|
+
```tsx
|
|
369
|
+
const accepted = controller.highlightRanges(["B3:E8", "G3:J8"], { autoScroll: false });
|
|
370
|
+
controller.highlightRanges("'Sheet 1'!A40:D48");
|
|
371
|
+
controller.highlightRanges("B3:E8", { sheetIndex: 1 });
|
|
372
|
+
controller.clearHighlightedRanges();
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
`highlightRanges(references, options?)` accepts a string or a readonly array of strings and returns `true` when every reference resolves to a loaded, visible worksheet. It returns `false` for invalid references, unavailable worksheets, or a workbook that is still loading, leaving all current highlights and navigation unchanged. Validation is atomic; a partially valid array is never applied. `autoScroll` defaults to `true`; `sheetIndex` is a zero-based index into `controller.sheets` and applies only to unqualified references. Each successful call replaces all previous highlights; an empty array clears them. Calling again can reveal the same first range again. `controller.highlightedRanges` is an array of parsed references with their resolved sheet names and workbook sheet indexes. Only its first entry can have `autoScroll: true`. Loading another workbook clears the array.
|
|
376
|
+
|
|
377
|
+
### CSS Customization
|
|
378
|
+
|
|
379
|
+
Style `.react-xlsx-range-highlight` globally, or use `highlightClassName` for a scoped override. Appearance is CSS in both renderers, so ordinary CSS properties work without `!important`:
|
|
380
|
+
|
|
381
|
+
```css
|
|
382
|
+
.my-range-highlight {
|
|
383
|
+
border: 1px solid #0284c7;
|
|
384
|
+
background: rgb(2 132 199 / 10%);
|
|
385
|
+
border-radius: 3px;
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
The defaults also accept inherited `--xlsx-highlight-border`, `--xlsx-highlight-fill`, and `--xlsx-highlight-radius` custom properties on the viewer or any ancestor. Position and dimensions are managed by the viewer; the overlay ignores pointer events. Use `[data-xlsx-range-highlight="1"]` to style a particular range by its zero-based index in the input array. A range crossing frozen panes may have several clipped overlay elements, each carrying the same class and index.
|
|
390
|
+
|
|
391
|
+
### Parsing References
|
|
392
|
+
|
|
393
|
+
`parseXlsxRange(reference)` validates a reference without loading a workbook. It returns `{ kind, range: { start, end }, sheetName }` with normalized, zero-based coordinates, or `null` for invalid input. `kind` is `"cells"`, `"rows"`, or `"columns"`; `sheetName` is `null` for an unqualified reference.
|
|
394
|
+
|
|
395
|
+
Supported references include single cells (`A1`), rectangles (`B2:E8`), absolute or mixed references (`$B2:E$8`), entire rows (`2:8`), entire columns (`B:E`), and optional worksheet prefixes. Sheet names with spaces or punctuation must be single-quoted; embedded apostrophes are doubled (`'Owner''s Data'!A1`). Letter case, reversed endpoints, surrounding whitespace, and an optional leading `=` are accepted. Coordinates are checked against [Excel's worksheet limits](https://support.microsoft.com/en-us/excel/excel-specifications-and-limits).
|
|
396
|
+
|
|
397
|
+
Each string must contain one rectangular A1 reference, not named ranges, structured table references, unions, R1C1 notation, external workbooks, or references spanning multiple worksheets. Whole-row/column highlights cover the displayed grid and extend as it grows.
|
|
398
|
+
|
|
347
399
|
## Custom Rendering
|
|
348
400
|
|
|
349
401
|
The viewer exposes render props for common UI integration points.
|
|
@@ -493,6 +545,9 @@ Common rendering props:
|
|
|
493
545
|
- `enableGestureZoom?: boolean`
|
|
494
546
|
- `enableCanvasSelectionAnimation?: boolean`
|
|
495
547
|
- `allowResizeInReadOnly?: boolean`
|
|
548
|
+
- `highlightedRanges?: string | readonly string[] | null`
|
|
549
|
+
- `autoScrollToHighlightedRanges?: boolean`
|
|
550
|
+
- `highlightClassName?: string`
|
|
496
551
|
- `selectionColor?: string`
|
|
497
552
|
- `selectionFillColor?: string`
|
|
498
553
|
- `selectionHeaderColor?: string`
|
|
@@ -681,6 +736,7 @@ The package exports the main types you are likely to use for custom integrations
|
|
|
681
736
|
- `XlsxTable`, `XlsxTableColumn`, `XlsxTableHeaderMenuRenderProps`
|
|
682
737
|
- `XlsxActiveCellOverlayRenderProps`
|
|
683
738
|
- `XlsxWorkbookTab`, `XlsxCellAddress`, `XlsxCellRange`
|
|
739
|
+
- `XlsxParsedRange`, `XlsxRangeHighlight`, `XlsxHighlightRangeOptions`
|
|
684
740
|
|
|
685
741
|
## License
|
|
686
742
|
|