@ticatec/batch-data-uploader 0.1.3 → 0.1.4

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.
@@ -29,6 +29,7 @@ export default abstract class BaseTemplate {
29
29
  */
30
30
  protected getCellValue(r: number, c: number): any;
31
31
  protected extractFormAttributes(): void;
32
+ protected appendMoreFields(rowData: any, data: any): void;
32
33
  protected extractData(arr: Array<any>): any[];
33
34
  protected wrapData(data: any): any;
34
35
  get columns(): Array<TableColumn>;
@@ -25,7 +25,7 @@ export default class BaseTemplate {
25
25
  this._list = [];
26
26
  try {
27
27
  const buffer = await file.arrayBuffer();
28
- this._workbook = XLSX.read(buffer, { type: 'array' });
28
+ this._workbook = XLSX.read(buffer, { type: 'array', cellNF: true });
29
29
  if (!this._workbook.SheetNames || this._workbook.SheetNames.length === 0) {
30
30
  throw new Error('Excel file contains no worksheets');
31
31
  }
@@ -128,10 +128,17 @@ export default class BaseTemplate {
128
128
  const cellAddress = { r, c };
129
129
  const cellRef = XLSX.utils.encode_cell(cellAddress);
130
130
  const cell = sheet[cellRef];
131
- return cell ? cell.v : null;
131
+ if (!cell || cell.v === undefined)
132
+ return null;
133
+ if (cell.t === 'n' && cell.z && /y|m|d|h|s/i.test(cell.z)) {
134
+ return new Date(Math.round((cell.v - 25569) * 86400 * 1000));
135
+ }
136
+ return cell.v;
132
137
  }
133
138
  extractFormAttributes() {
134
139
  }
140
+ appendMoreFields(rowData, data) {
141
+ }
135
142
  extractData(arr) {
136
143
  return arr.map(item => {
137
144
  let result = {};
@@ -141,6 +148,7 @@ export default class BaseTemplate {
141
148
  utils.setNestedValue(result, col.field, utils.getNestedValue(data, col.field));
142
149
  }
143
150
  }
151
+ this.appendMoreFields(item.data, result);
144
152
  return result;
145
153
  });
146
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticatec/batch-data-uploader",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
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",