BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/retab-ui/xlsx-sheetjs-flattener

XLSX SheetJS flattener

retab-ui/xlsx-sheetjs-flattener
FreeUtility

Pure SheetJS-to-compact-sheet flattening helpers for the XLSX viewer worker.

Install it

npx shadcn@latest add https://ui.retab.com/r/xlsx-sheetjs-flattener.json

Source

registry/new-york-v4/lib/xlsx-sheetjs-flattener.tsui.retab.com/r/xlsx-sheetjs-flattener.json
1import * as XLSX from "@e965/xlsx";
2
3import { createCompactSheet, type CompactSheet } from "@/lib/xlsx-workbook";
4import {
5 XLSX_PARSE_LIMITS,
6 XlsxWorkerError,
7 type XlsxParseLimits,
8} from "@/lib/xlsx-worker-protocol";
9
10type SheetJsCell = {
11 t?: string;
12 v?: unknown;
13 w?: unknown;
14};
15
16type SheetJsWorksheet = Record<string, SheetJsCell | string | undefined>;
17
18type SheetJsWorkbook = {
19 SheetNames: string[];
20 Sheets: Record<string, SheetJsWorksheet | undefined>;
21};
22
23export function flattenSheetJsWorkbook(
24 workbook: SheetJsWorkbook,
25 limits: XlsxParseLimits = XLSX_PARSE_LIMITS,
26): CompactSheet[] {
27 return workbook.SheetNames.map((name) =>
28 flattenSheetJsWorksheet(name, workbook.Sheets[name], limits),
29 );
30}
31
32export function flattenSheetJsWorksheet(
33 name: string,
34 worksheet: SheetJsWorksheet | undefined,
35 limits: XlsxParseLimits = XLSX_PARSE_LIMITS,
36): CompactSheet {
37 const ref = worksheet?.["!ref"];
38 if (typeof ref !== "string") {
39 return createEmptyCompactSheet(name);
40 }
41 const source = worksheet as SheetJsWorksheet;
42
43 const range = XLSX.utils.decode_range(ref);
44 if (!isValidDecodedRange(range)) return createEmptyCompactSheet(name);
45 const rowCount = range.e.r + 1;
46 const columnCount = range.e.c + 1;
47 const maxIndex = rowCount * columnCount - 1;
48 if (maxIndex > limits.maxRowMajorIndex) {
49 throw new XlsxWorkerError(
50 "range_too_large",
51 `Spreadsheet range is too large to preview (${rowCount} rows x ${columnCount} columns)`,
52 );
53 }
54
55 const entries: Array<{
56 cellIndex: number;
57 text: string;
58 numeric?: boolean;
59 }> = [];
60 let textChars = 0;
61
62 for (const key of Object.keys(source)) {
63 if (key.charCodeAt(0) === 33) continue;
64 const cell = source[key];
65 if (!isSheetJsCell(cell)) continue;
66 const { c: columnIndex, r: rowIndex } = XLSX.utils.decode_cell(key);
67 if (
68 rowIndex < range.s.r ||
69 columnIndex < range.s.c ||
70 rowIndex >= rowCount ||
71 columnIndex >= columnCount
72 ) {
73 continue;
74 }
75
76 const text =
77 cell.w != null ? String(cell.w) : cell.v != null ? String(cell.v) : "";
78 if (text === "") continue;
79 if (entries.length >= limits.maxNonEmptyCells) {
80 throw new XlsxWorkerError(
81 "too_many_cells",
82 `Spreadsheet has too many non-empty cells to preview (>${limits.maxNonEmptyCells.toLocaleString()})`,
83 );
84 }
85 textChars += text.length;
86 if (textChars > limits.maxTextChars) {
87 throw new XlsxWorkerError(
88// … truncated

What it pulls in

npm packages

  • @e965/xlsx@0.20.3

Other registry items

  • @retab/xlsx-worker-protocol
  • @retab/xlsx-workbook

Files it writes

  • registry/new-york-v4/lib/xlsx-sheetjs-flattener.ts

Facts

Registry
retab-ui
Type
registry:lib
Access
Free
Files written
1
Licence
NOASSERTION
In the index
at or before 2026-08-05
Last confirmed
today

Go to the source

ui.retab.com retab-dev/retab-ui on GitHub Raw registry item This item as JSON

More from retab-ui

All 130 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
CSV parsercsvretab-uiUtilitiesFreeno deps · 4 files
Document source modeldocument-sourceretab-uiUtilitiesFreeno deps
DOCX Document Resourcedocx-document-resourceretab-uiUtilitiesFreeno deps · 5 files
Effect Keyeffect-keyretab-uiUtilitiesFreeno deps
PDF Document Resourcepdf-document-resourceretab-uiUtilitiesFree1 dep · 6 files
Segment Interactionsegment-interactionretab-uiUtilitiesFreeno deps
Segments modelsegmentsretab-uiUtilitiesFreeno deps
Utilsutilsretab-uiUtilitiesFree2 deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex