vxe-table-plugin-export-xlsx-xhx 1.0.6 → 1.0.8
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/index.common.js +13 -10
- package/dist/index.js +12 -12
- package/package.json +1 -1
package/dist/index.common.js
CHANGED
@@ -15,7 +15,8 @@ function getCellLabel(column, cellValue) {
|
|
15
15
|
if (cellValue) {
|
16
16
|
switch (column.cellType) {
|
17
17
|
case 'string':
|
18
|
-
return _xeUtils["default"].toValueString(cellValue);
|
18
|
+
// return _xeUtils["default"].toValueString(cellValue);
|
19
|
+
return _xeUtils.toValueString(cellValue);
|
19
20
|
case 'number':
|
20
21
|
if (!isNaN(cellValue)) {
|
21
22
|
return Number(cellValue);
|
@@ -31,7 +32,9 @@ function getCellLabel(column, cellValue) {
|
|
31
32
|
return cellValue;
|
32
33
|
}
|
33
34
|
function getFooterCellValue($table, opts, rows, column) {
|
34
|
-
var cellValue = _xeUtils["default"].toString(rows[$table.$getColumnIndex(column)]);
|
35
|
+
// var cellValue = _xeUtils["default"].toString(rows[$table.$getColumnIndex(column)]);
|
36
|
+
var cellValue = _xeUtils.toString(rows[$table.$getColumnIndex(column)]);
|
37
|
+
|
35
38
|
return cellValue;
|
36
39
|
}
|
37
40
|
function toBuffer(wbout) {
|
@@ -60,7 +63,7 @@ function exportXLSX(params) {
|
|
60
63
|
if (isHeader) {
|
61
64
|
columns.forEach(function (column) {
|
62
65
|
// colHead[column.id] = XEUtils.toString(original ? column.property : column.getTitle())
|
63
|
-
colHead[column.id] = _xeUtils
|
66
|
+
colHead[column.id] = _xeUtils.toString(original ? column.property : column.getTitle());
|
64
67
|
});
|
65
68
|
}
|
66
69
|
// 新增部分
|
@@ -83,13 +86,13 @@ function exportXLSX(params) {
|
|
83
86
|
footList.push(item);
|
84
87
|
});
|
85
88
|
}
|
86
|
-
var book = _xlsx
|
87
|
-
var sheet = _xlsx
|
89
|
+
var book = _xlsx.utils.book_new();
|
90
|
+
var sheet = _xlsx.utils.json_to_sheet((isHeader ? [colHead] : []).concat(rowList).concat(footList), {
|
88
91
|
skipHeader: true
|
89
92
|
});
|
90
93
|
// 转换数据
|
91
|
-
_xlsx
|
92
|
-
var wbout = _xlsx
|
94
|
+
_xlsx.utils.book_append_sheet(book, sheet, sheetName);
|
95
|
+
var wbout = _xlsx.write(book, {
|
93
96
|
bookType: type,
|
94
97
|
bookSST: false,
|
95
98
|
type: 'binary'
|
@@ -172,10 +175,10 @@ function importXLSX(params) {
|
|
172
175
|
var _importResolve = $table._importResolve;
|
173
176
|
var fileReader = new FileReader();
|
174
177
|
fileReader.onload = function (e) {
|
175
|
-
var workbook = _xlsx
|
178
|
+
var workbook = _xlsx.read(e.target.result, {
|
176
179
|
type: 'binary'
|
177
180
|
});
|
178
|
-
var csvData = _xlsx
|
181
|
+
var csvData = _xlsx.utils.sheet_to_csv(workbook.Sheets.Sheet1);
|
179
182
|
var _parseCsv = parseCsv(columns, csvData),
|
180
183
|
fields = _parseCsv.fields,
|
181
184
|
rows = _parseCsv.rows;
|
@@ -190,7 +193,7 @@ function importXLSX(params) {
|
|
190
193
|
});
|
191
194
|
if (options.message !== false) {
|
192
195
|
_vxetable.modal.message({
|
193
|
-
message: _xeUtils
|
196
|
+
message: _xeUtils.template(_vxetable.t('vxe.table.impSuccess'), [rows.length]),
|
194
197
|
status: 'success'
|
195
198
|
});
|
196
199
|
}
|
package/dist/index.js
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
Object.defineProperty(_exports, "__esModule", {
|
17
17
|
value: true
|
18
18
|
});
|
19
|
-
_exports
|
19
|
+
_exports = _exports.VXETablePluginExportXLSX = void 0;
|
20
20
|
_xeUtils = _interopRequireDefault(_xeUtils);
|
21
21
|
_xlsx = _interopRequireDefault(_xlsx);
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
@@ -28,7 +28,7 @@
|
|
28
28
|
if (cellValue) {
|
29
29
|
switch (column.cellType) {
|
30
30
|
case 'string':
|
31
|
-
return _xeUtils
|
31
|
+
return _xeUtils.toValueString(cellValue);
|
32
32
|
case 'number':
|
33
33
|
if (!isNaN(cellValue)) {
|
34
34
|
return Number(cellValue);
|
@@ -44,7 +44,7 @@
|
|
44
44
|
return cellValue;
|
45
45
|
}
|
46
46
|
function getFooterCellValue($table, opts, rows, column) {
|
47
|
-
var cellValue = _xeUtils
|
47
|
+
var cellValue = _xeUtils.toString(rows[$table.$getColumnIndex(column)]);
|
48
48
|
return cellValue;
|
49
49
|
}
|
50
50
|
function toBuffer(wbout) {
|
@@ -73,7 +73,7 @@
|
|
73
73
|
if (isHeader) {
|
74
74
|
columns.forEach(function (column) {
|
75
75
|
// colHead[column.id] = XEUtils.toString(original ? column.property : column.getTitle())
|
76
|
-
colHead[column.id] = _xeUtils
|
76
|
+
colHead[column.id] = _xeUtils.toString(original ? column.property : column.getTitle());
|
77
77
|
});
|
78
78
|
}
|
79
79
|
// 新增部分
|
@@ -96,13 +96,13 @@
|
|
96
96
|
footList.push(item);
|
97
97
|
});
|
98
98
|
}
|
99
|
-
var book = _xlsx
|
100
|
-
var sheet = _xlsx
|
99
|
+
var book = _xlsx.utils.book_new();
|
100
|
+
var sheet = _xlsx.utils.json_to_sheet((isHeader ? [colHead] : []).concat(rowList).concat(footList), {
|
101
101
|
skipHeader: true
|
102
102
|
});
|
103
103
|
// 转换数据
|
104
|
-
_xlsx
|
105
|
-
var wbout = _xlsx
|
104
|
+
_xlsx.utils.book_append_sheet(book, sheet, sheetName);
|
105
|
+
var wbout = _xlsx.write(book, {
|
106
106
|
bookType: type,
|
107
107
|
bookSST: false,
|
108
108
|
type: 'binary'
|
@@ -185,10 +185,10 @@
|
|
185
185
|
var _importResolve = $table._importResolve;
|
186
186
|
var fileReader = new FileReader();
|
187
187
|
fileReader.onload = function (e) {
|
188
|
-
var workbook = _xlsx
|
188
|
+
var workbook = _xlsx.read(e.target.result, {
|
189
189
|
type: 'binary'
|
190
190
|
});
|
191
|
-
var csvData = _xlsx
|
191
|
+
var csvData = _xlsx.utils.sheet_to_csv(workbook.Sheets.Sheet1);
|
192
192
|
var _parseCsv = parseCsv(columns, csvData),
|
193
193
|
fields = _parseCsv.fields,
|
194
194
|
rows = _parseCsv.rows;
|
@@ -203,7 +203,7 @@
|
|
203
203
|
});
|
204
204
|
if (options.message !== false) {
|
205
205
|
_vxetable.modal.message({
|
206
|
-
message: _xeUtils
|
206
|
+
message: _xeUtils.template(_vxetable.t('vxe.table.impSuccess'), [rows.length]),
|
207
207
|
status: 'success'
|
208
208
|
});
|
209
209
|
}
|
@@ -253,5 +253,5 @@
|
|
253
253
|
window.VXETable.use(VXETablePluginExportXLSX);
|
254
254
|
}
|
255
255
|
var _default = VXETablePluginExportXLSX;
|
256
|
-
_exports
|
256
|
+
_exports = _default;
|
257
257
|
});
|