@senlinz/import-export 0.1.1 → 0.1.2
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 +5 -0
- package/README.zh.md +5 -0
- package/dist/index.js +1 -1
- package/dist/types/ExcelDefinition.d.ts +6 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils.d.ts +22 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -51,12 +51,14 @@ If you provide invalid manual input, `initializeWasm(...)` throws a clear error
|
|
|
51
51
|
- `columns` - stable schema for headers, validation, and row mapping
|
|
52
52
|
- `author` - optional workbook author metadata
|
|
53
53
|
- `createTime` - optional workbook creation time as a `Date` or date string
|
|
54
|
+
- `maxFileSizeBytes` - browser upload limit in bytes (default 25 MiB) enforced before reading a file
|
|
54
55
|
- `title`, `titleHeight`, `titleFormat` - optional merged title row and its layout/format
|
|
55
56
|
- `defaultRowHeight`, `headerRowHeight` - row heights for exported data rows and header rows
|
|
56
57
|
- `dx`, `dy` - horizontal and vertical offsets before the header starts
|
|
57
58
|
- `isHeaderFreeze` - freezes the header area so column labels stay visible while scrolling
|
|
58
59
|
- `progressCallback` - progress hook for long-running import/export work
|
|
59
60
|
- `imageFetcher` - required resolver for `image` columns during export
|
|
61
|
+
- `escapeFormulas` - escapes formula-like text during export to block Excel formula injection (default: enabled)
|
|
60
62
|
|
|
61
63
|
### Schema-less import
|
|
62
64
|
|
|
@@ -91,6 +93,7 @@ console.log(result.rows);
|
|
|
91
93
|
- `importExcelDynamic(...)` depends on DOM/browser file upload APIs.
|
|
92
94
|
- `sheetName` is optional and falls back to the first worksheet when missing.
|
|
93
95
|
- `headerRow` is optional, 1-based, and defaults to the first non-empty row in the selected sheet.
|
|
96
|
+
- `maxFileSizeBytes` is optional and uses the same default 25 MiB browser upload limit as schema-based import.
|
|
94
97
|
- The result shape is `{ sheetName, headers, rows }`.
|
|
95
98
|
- Dynamic import requires non-empty, unique header names in the selected header row.
|
|
96
99
|
|
|
@@ -150,6 +153,7 @@ const rows = await importExcel(definition);
|
|
|
150
153
|
- Empty imported `number` and `date` cells are returned as `null`.
|
|
151
154
|
- Imported `date` values are returned as formatted strings.
|
|
152
155
|
- Unknown or malformed schemas fail fast before any workbook operation starts.
|
|
156
|
+
- Browser uploads enforce `maxFileSizeBytes` before reading the file (default 25 MiB).
|
|
153
157
|
- Use `importExcelDynamic(...)` for browser uploads without a schema, or `fromExcelDynamic(...)` when you already have workbook bytes.
|
|
154
158
|
|
|
155
159
|
## Export behavior
|
|
@@ -157,6 +161,7 @@ const rows = await importExcel(definition);
|
|
|
157
161
|
- `null` and `undefined` values are exported as blank cells.
|
|
158
162
|
- Number columns reject non-finite values.
|
|
159
163
|
- Date columns accept `Date` instances or parseable date strings.
|
|
164
|
+
- Text columns escape values that look like formulas by default; set `escapeFormulas: false` to allow formulas intentionally.
|
|
160
165
|
- Grouped export objects must use `{ value?, children: [...] }` for configured `dataGroup` columns.
|
|
161
166
|
- Image columns require `imageFetcher`.
|
|
162
167
|
|
package/README.zh.md
CHANGED
|
@@ -51,12 +51,14 @@ const workbook = await toExcel({
|
|
|
51
51
|
- `columns`:表头、校验和行映射使用的稳定列定义
|
|
52
52
|
- `author`:可选的工作簿作者元数据
|
|
53
53
|
- `createTime`:可选的工作簿创建时间,支持 `Date` 或日期字符串
|
|
54
|
+
- `maxFileSizeBytes`:浏览器上传的字节大小上限(默认 25 MiB),在读取前先校验
|
|
54
55
|
- `title`、`titleHeight`、`titleFormat`:可选的合并标题行及其高度、样式
|
|
55
56
|
- `defaultRowHeight`、`headerRowHeight`:导出时数据行和表头行的行高
|
|
56
57
|
- `dx`、`dy`:表头写入前的横向、纵向偏移量
|
|
57
58
|
- `isHeaderFreeze`:冻结表头区域,滚动时仍保持列标题可见
|
|
58
59
|
- `progressCallback`:长时间导入 / 导出过程中的进度回调
|
|
59
60
|
- `imageFetcher`:导出 `image` 列时必需的图片数据解析回调
|
|
61
|
+
- `escapeFormulas`:导出时自动转义类似公式的文本,默认开启,可显式关闭以允许公式
|
|
60
62
|
|
|
61
63
|
### 稳定的列字段
|
|
62
64
|
|
|
@@ -134,6 +136,7 @@ const result = await fromExcelDynamic(fileBytes, {
|
|
|
134
136
|
- `importExcelDynamic(...)` 依赖 DOM / 浏览器文件上传 API。
|
|
135
137
|
- `sheetName` 可选,未提供或不存在时会回退到第一个工作表。
|
|
136
138
|
- `headerRow` 可选,使用从 `1` 开始的行号,默认会自动选择首个非空行。
|
|
139
|
+
- `maxFileSizeBytes` 可选,与 schema 导入相同,默认 25 MiB。
|
|
137
140
|
- 返回值结构为 `{ sheetName, headers, rows }`。
|
|
138
141
|
|
|
139
142
|
## 导入行为
|
|
@@ -143,6 +146,7 @@ const result = await fromExcelDynamic(fileBytes, {
|
|
|
143
146
|
- 空的 `number` / `date` 单元格导入后返回 `null`。
|
|
144
147
|
- `date` 列导入后返回格式化字符串。
|
|
145
148
|
- 非法或不完整的 schema 会在读取工作簿前立即失败。
|
|
149
|
+
- 浏览器上传会在读取前按 `maxFileSizeBytes` 校验文件大小(默认 25 MiB)。
|
|
146
150
|
- 无 schema 导入时,可使用 `importExcelDynamic(...)`(浏览器上传)或 `fromExcelDynamic(...)`(字节缓冲)。
|
|
147
151
|
|
|
148
152
|
## 导出行为
|
|
@@ -150,6 +154,7 @@ const result = await fromExcelDynamic(fileBytes, {
|
|
|
150
154
|
- `null` 和 `undefined` 会导出为空单元格。
|
|
151
155
|
- 数字列会拒绝非有限值。
|
|
152
156
|
- 日期列支持 `Date` 实例或日期字符串。
|
|
157
|
+
- 文本列默认会转义看起来像公式的值;如需导出公式,可设置 `escapeFormulas: false`。
|
|
153
158
|
- 分组导出对象必须使用 `{ value?, children: [...] }` 结构。
|
|
154
159
|
- 图片列必须提供 `imageFetcher`。
|
|
155
160
|
|