@mdgate/xlsx 0.6.8 → 0.6.10

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.
Files changed (2) hide show
  1. package/README.md +169 -8
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,26 +1,187 @@
1
1
  # @mdgate/xlsx
2
2
 
3
- Convert Excel workbooks to Markdown tables. Outputs GitHub-Flavored Markdown. Works in Node, Edge, and
4
- browsers. No native addons.
3
+ **Convert Excel workbooks to Markdown in TypeScript.**
5
4
 
6
- Handles: `.xlsx`, `.xlsm`, `.xlsb`, `.xls`, `.xltx`, `.xltm`, `.xlt`
5
+ [`@mdgate/xlsx`](https://github.com/mdgate/converters/tree/main/packages/xlsx) reads `.xlsx`, `.xlsm`, `.xlsb`, `.xls`, `.xltx`, `.xltm`, and `.xlt` files directly in JavaScript and converts sheets into GitHub-Flavored Markdown tables, without Python, native addons, WASM, or Excel.
7
6
 
8
- ## Usage
7
+ Works in **Node.js, Cloudflare Workers, Edge runtimes, and browsers**.
8
+
9
+ ```bash
10
+ npm install @mdgate/xlsx
11
+ ```
12
+
13
+ ```ts
14
+ import { toMarkdown } from '@mdgate/xlsx';
15
+
16
+ const markdown = await toMarkdown(bytes);
17
+ ```
18
+
19
+ `bytes` is a `Uint8Array`, so the workbook can come from a file upload, object storage, an HTTP request, a browser file picker, or anywhere else your application gets bytes.
20
+
21
+ ---
22
+
23
+ ## Why [`@mdgate/xlsx`](https://github.com/mdgate/converters/tree/main/packages/xlsx)
24
+
25
+ Spreadsheets are how a lot of operational truth is stored: inventories, reports, exports from other systems.
26
+
27
+ [`@mdgate/xlsx`](https://github.com/mdgate/converters/tree/main/packages/xlsx) is a workbook reader written for the same runtime as your application:
28
+
29
+ * **Pure TypeScript**
30
+ * **Excel → Markdown locally**
31
+ * **No Python runtime**
32
+ * **No native addons**
33
+ * **No WASM runtime**
34
+ * **Zero third-party runtime dependencies**
35
+ * **Works with raw `Uint8Array` input**
36
+ * **Detects Excel packages and binary workbooks from their contents, not only the filename**
37
+
38
+ Use it when an agent or search index needs sheet contents as text, not a spreadsheet UI.
39
+
40
+ ---
41
+
42
+ ## What it extracts
43
+
44
+ [`@mdgate/xlsx`](https://github.com/mdgate/converters/tree/main/packages/xlsx) parses OOXML, XLSB, and binary `.xls` workbooks into a shared document model.
45
+
46
+ The converter handles Excel-specific concerns including:
47
+
48
+ * one Markdown section per sheet
49
+ * GitHub-Flavored Markdown tables
50
+ * merged cells
51
+ * header-row detection
52
+ * number formats (dates, percents, currency-style text)
53
+ * shared strings and typed cell values
54
+ * encrypted workbook detection
55
+
56
+ The output is Markdown that can be searched, indexed, chunked, cached, or passed directly to an AI agent.
57
+
58
+ CSV is a different format. Use [`@mdgate/csv`](https://github.com/mdgate/converters/tree/main/packages/csv) for `.csv` / `.tsv`.
59
+
60
+ ---
61
+
62
+ ## Node.js
63
+
64
+ ```ts
65
+ import { readFile } from 'node:fs/promises';
66
+ import { toMarkdown } from '@mdgate/xlsx';
67
+
68
+ const bytes = new Uint8Array(await readFile('sheet.xlsx'));
69
+ const markdown = await toMarkdown(bytes);
70
+
71
+ console.log(markdown);
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Browser
77
+
78
+ ```ts
79
+ import { toMarkdown } from '@mdgate/xlsx';
80
+
81
+ const file = input.files![0];
82
+ const bytes = new Uint8Array(await file.arrayBuffer());
83
+
84
+ const markdown = await toMarkdown(bytes);
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Cloudflare Workers and Edge runtimes
9
90
 
10
91
  ```ts
11
92
  import { toMarkdown } from '@mdgate/xlsx';
12
93
 
94
+ export default {
95
+ async fetch(request: Request) {
96
+ const bytes = new Uint8Array(await request.arrayBuffer());
97
+ const markdown = await toMarkdown(bytes);
98
+
99
+ return new Response(markdown, {
100
+ headers: {
101
+ 'content-type': 'text/markdown; charset=utf-8',
102
+ },
103
+ });
104
+ },
105
+ };
106
+ ```
107
+
108
+ ```text
109
+ upload XLSX
110
+
111
+ Cloudflare Worker
112
+
113
+ @mdgate/xlsx
114
+
115
+ Markdown
116
+
117
+ agent / search / index / storage
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Format detection
123
+
124
+ You do not need to trust the file extension.
125
+
126
+ [`@mdgate/xlsx`](https://github.com/mdgate/converters/tree/main/packages/xlsx) recognizes Excel OOXML packages and binary `.xls` OLE streams from their contents.
127
+
128
+ ```ts
13
129
  const markdown = await toMarkdown(bytes);
14
130
  ```
15
131
 
16
- Compose with other converters:
132
+ A path can still be supplied as a format hint when [`@mdgate/xlsx`](https://github.com/mdgate/converters/tree/main/packages/xlsx) is used through [`@mdgate/converters`](https://github.com/mdgate/converters/tree/main/packages/converters) or a reader composed with [`@mdgate/core`](https://github.com/mdgate/converters/tree/main/packages/core), but the path is never used to read a file from disk.
133
+
134
+ ---
135
+
136
+ ## Encrypted workbooks
137
+
138
+ Encrypted or password-protected workbooks are reported as encrypted rather than returning misleading partial output.
139
+
140
+ ---
141
+
142
+ ## Compose it with other file readers
143
+
144
+ [`@mdgate/xlsx`](https://github.com/mdgate/converters/tree/main/packages/xlsx) implements the converter interface from [`@mdgate/core`](https://github.com/mdgate/converters/tree/main/packages/core).
17
145
 
18
146
  ```ts
19
147
  import { create } from '@mdgate/core';
20
148
  import { xlsx } from '@mdgate/xlsx';
149
+ import { csv } from '@mdgate/csv';
150
+ import { pdf } from '@mdgate/pdf';
151
+
152
+ const read = create([
153
+ xlsx(),
154
+ csv(),
155
+ pdf(),
156
+ ]);
157
+ ```
158
+
159
+ The application still uses one reading interface while each format remains independently installable.
160
+
161
+ ---
162
+
163
+ ## Need more than Excel?
21
164
 
22
- const convert = create([xlsx()]);
165
+ If your application needs to read many different file types, use the complete converter set:
166
+
167
+ ```bash
168
+ npm install @mdgate/converters
169
+ ```
170
+
171
+ ```ts
172
+ import { toMarkdown } from '@mdgate/converters';
173
+
174
+ const markdown = await toMarkdown(bytes, {
175
+ path: filename,
176
+ });
23
177
  ```
24
178
 
25
- Part of [mdgate converters](https://github.com/mdgate/converters); install
26
- `@mdgate/converters` for every format at once.
179
+ [`@mdgate/xlsx`](https://github.com/mdgate/converters/tree/main/packages/xlsx) is one of the single-format packages in the open-source [`mdgate/converters`](https://github.com/mdgate/converters) project.
180
+
181
+ For AI agents, the same converter architecture can be used to extend `read_file` from text files to real-world document formats.
182
+
183
+ ---
184
+
185
+ ## License
186
+
187
+ MIT
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@mdgate/xlsx",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "mdgate Excel converter (xlsx/xlsm/xlsb/xls)",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "homepage": "https://demo.mdgate.dev",
7
+ "homepage": "https://convert.mdgate.dev",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/mdgate/converters.git",
@@ -28,10 +28,10 @@
28
28
  "prepublishOnly": "bun run build"
29
29
  },
30
30
  "dependencies": {
31
- "@mdgate/containers": "0.6.8",
32
- "@mdgate/core": "0.6.8",
33
- "@mdgate/document": "0.6.8",
34
- "@mdgate/utils": "0.6.8"
31
+ "@mdgate/containers": "0.6.10",
32
+ "@mdgate/core": "0.6.10",
33
+ "@mdgate/document": "0.6.10",
34
+ "@mdgate/utils": "0.6.10"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"