@things-factory/import-ui-excel 4.3.700 → 4.3.701
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/client/bootstrap.js +8 -30
- package/package.json +2 -2
package/client/bootstrap.js
CHANGED
|
@@ -3,26 +3,6 @@ import { store } from '@things-factory/shell'
|
|
|
3
3
|
import * as XLSX from '!xlsx'
|
|
4
4
|
import Excel from '!exceljs'
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Normalize cell value - handles ExcelJS hyperlink objects and other object types
|
|
8
|
-
* @param {any} cellVal - The cell value from ExcelJS
|
|
9
|
-
* @return {any} - Normalized value (string for hyperlinks, original value otherwise)
|
|
10
|
-
*/
|
|
11
|
-
function normalizeCellValue(cellVal) {
|
|
12
|
-
// Handle ExcelJS hyperlink objects (e.g., { text: 'email@example.com', hyperlink: 'mailto:...' })
|
|
13
|
-
if (cellVal && typeof cellVal === 'object' && !Array.isArray(cellVal)) {
|
|
14
|
-
if (cellVal.text !== undefined) {
|
|
15
|
-
return cellVal.text
|
|
16
|
-
}
|
|
17
|
-
// For other object types, try to extract a meaningful value
|
|
18
|
-
if (cellVal.toString && cellVal.toString() !== '[object Object]') {
|
|
19
|
-
return cellVal.toString()
|
|
20
|
-
}
|
|
21
|
-
return ''
|
|
22
|
-
}
|
|
23
|
-
return cellVal
|
|
24
|
-
}
|
|
25
|
-
|
|
26
6
|
/**
|
|
27
7
|
* Convert Excel to Object
|
|
28
8
|
* @param {ArrayBufferTypes} params - Array Buffer of the excel file.
|
|
@@ -34,8 +14,7 @@ async function excelToObj(params) {
|
|
|
34
14
|
|
|
35
15
|
let ws = workbook.getWorksheet(1)
|
|
36
16
|
ws._rows[0]._cells.map((cell, index) => {
|
|
37
|
-
|
|
38
|
-
ws._columns[index]._key = cell.name || (typeof cellValue === 'string' ? cellValue.toLowerCase() : '')
|
|
17
|
+
ws._columns[index]._key = cell.name || cell.value.toLowerCase()
|
|
39
18
|
})
|
|
40
19
|
|
|
41
20
|
//Fetch supporting data and place it under 'extraData' object.
|
|
@@ -74,7 +53,7 @@ async function excelToObj(params) {
|
|
|
74
53
|
columnType = ws.dataValidations?.model[currentCell._address]?.type
|
|
75
54
|
}
|
|
76
55
|
|
|
77
|
-
let cellVal = currentCell ?
|
|
56
|
+
let cellVal = currentCell ? currentCell.value : ''
|
|
78
57
|
|
|
79
58
|
let arrColumnKeys = ws._columns[columncount].key?.split('.')
|
|
80
59
|
if (arrColumnKeys.length > 1) {
|
|
@@ -91,24 +70,23 @@ async function excelToObj(params) {
|
|
|
91
70
|
prev[e] = cellVal ? parseFloat(cellVal) : 0
|
|
92
71
|
break
|
|
93
72
|
default:
|
|
94
|
-
prev[e] = cellVal
|
|
73
|
+
prev[e] = cellVal ? cellVal.toString() : null
|
|
95
74
|
break
|
|
96
75
|
}
|
|
97
76
|
}
|
|
98
77
|
return prev[e]
|
|
99
78
|
}, objRow)
|
|
100
79
|
} else {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
80
|
+
if (
|
|
81
|
+
(ws._rows[0]._cells[columncount].value === 'id' && cellVal !== '') ||
|
|
82
|
+
ws._rows[0]._cells[columncount].value !== 'id'
|
|
83
|
+
) {
|
|
105
84
|
switch (columnType) {
|
|
106
85
|
case 'decimal':
|
|
107
86
|
objRow[ws._columns[columncount].key] = cellVal ? parseFloat(cellVal) : 0
|
|
108
87
|
break
|
|
109
88
|
default:
|
|
110
|
-
objRow[ws._columns[columncount].key] =
|
|
111
|
-
cellVal !== null && cellVal !== undefined ? cellVal.toString() : null
|
|
89
|
+
objRow[ws._columns[columncount].key] = cellVal ? cellVal.toString() : null
|
|
112
90
|
break
|
|
113
91
|
}
|
|
114
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/import-ui-excel",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.701",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"@things-factory/layout-base": "^4.3.695",
|
|
28
28
|
"xlsx": "^0.16.8"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "2cb46fe9d95770899e069846c590a3b24c847d9c"
|
|
31
31
|
}
|