@ticatec/batch-data-uploader 0.1.2 → 0.1.3
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/dist/BaseTemplate.d.ts +7 -0
- package/dist/BaseTemplate.js +20 -0
- package/package.json +1 -1
package/dist/BaseTemplate.d.ts
CHANGED
|
@@ -22,6 +22,13 @@ export default abstract class BaseTemplate {
|
|
|
22
22
|
* @param sheetName 如果不传则使用第一个工作表
|
|
23
23
|
*/
|
|
24
24
|
parseSheet(sheetName?: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* 方便函数:根据行号和列号(从0开始)获取单元格的值
|
|
27
|
+
* @param r 行索引 (0 表示第1行)
|
|
28
|
+
* @param c 列索引 (0 表示第A列)
|
|
29
|
+
*/
|
|
30
|
+
protected getCellValue(r: number, c: number): any;
|
|
31
|
+
protected extractFormAttributes(): void;
|
|
25
32
|
protected extractData(arr: Array<any>): any[];
|
|
26
33
|
protected wrapData(data: any): any;
|
|
27
34
|
get columns(): Array<TableColumn>;
|
package/dist/BaseTemplate.js
CHANGED
|
@@ -61,6 +61,7 @@ export default class BaseTemplate {
|
|
|
61
61
|
if (range.e.r < rowOffset) {
|
|
62
62
|
throw new Error(`Not enough rows in sheet "${targetSheetName}". Expected at least ${rowOffset + 1} rows`);
|
|
63
63
|
}
|
|
64
|
+
this.extractFormAttributes();
|
|
64
65
|
const rows = [];
|
|
65
66
|
for (let rowIndex = range.s.r + rowOffset; rowIndex <= range.e.r; rowIndex++) {
|
|
66
67
|
const rowObject = {};
|
|
@@ -112,6 +113,25 @@ export default class BaseTemplate {
|
|
|
112
113
|
throw new Error(`Failed to parse sheet "${targetSheetName}": ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
113
114
|
}
|
|
114
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* 方便函数:根据行号和列号(从0开始)获取单元格的值
|
|
118
|
+
* @param r 行索引 (0 表示第1行)
|
|
119
|
+
* @param c 列索引 (0 表示第A列)
|
|
120
|
+
*/
|
|
121
|
+
getCellValue(r, c) {
|
|
122
|
+
if (!this._workbook || !this._currentSheetName) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const sheet = this._workbook.Sheets[this._currentSheetName];
|
|
126
|
+
if (!sheet)
|
|
127
|
+
return null;
|
|
128
|
+
const cellAddress = { r, c };
|
|
129
|
+
const cellRef = XLSX.utils.encode_cell(cellAddress);
|
|
130
|
+
const cell = sheet[cellRef];
|
|
131
|
+
return cell ? cell.v : null;
|
|
132
|
+
}
|
|
133
|
+
extractFormAttributes() {
|
|
134
|
+
}
|
|
115
135
|
extractData(arr) {
|
|
116
136
|
return arr.map(item => {
|
|
117
137
|
let result = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ticatec/batch-data-uploader",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A reusable Svelte component for batch uploading Excel data with support for error handling, multi-language, and preprocessing.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|