Skip to content

Commit 513ae48

Browse files
committed
fix: int cells were not supported in dataSet format
1 parent 9a630c4 commit 513ae48

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

Diff for: dist/ExcelPlugin/utils/DataUtil.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,28 @@ function getHeaderCell(v, cellRef, ws) {
100100
}
101101

102102
function getCell(v, cellRef, ws) {
103-
var cell = {};
103+
//assume v is indeed the value. for other cases (object, date...) it will be overriden.
104+
var cell = { v: v };
104105
if (v === null) {
105106
return;
106107
}
108+
109+
var isDate = v instanceof Date;
110+
if (!isDate && (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object') {
111+
cell.s = v.style;
112+
cell.v = v.value;
113+
v = v.value;
114+
}
115+
107116
if (typeof v === 'number') {
108-
cell.v = v;
109117
cell.t = 'n';
110118
} else if (typeof v === 'boolean') {
111-
cell.v = v;
112119
cell.t = 'b';
113-
} else if (v instanceof Date) {
120+
} else if (isDate) {
114121
cell.t = 'n';
115122
cell.z = _xlsx2.default.SSF._table[14];
116123
cell.v = dateToNumber(cell.v);
117-
} else if ((typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object') {
118-
cell.v = v.value;
119-
cell.s = v.style;
120124
} else {
121-
cell.v = v;
122125
cell.t = 's';
123126
}
124127
ws[cellRef] = cell;

Diff for: src/ExcelPlugin/utils/DataUtil.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,29 @@ function getHeaderCell(v, cellRef, ws) {
8787
}
8888

8989
function getCell(v, cellRef, ws) {
90-
var cell = {};
90+
//assume v is indeed the value. for other cases (object, date...) it will be overriden.
91+
var cell = {v};
9192
if (v === null) {
9293
return;
9394
}
95+
96+
97+
var isDate = (v instanceof Date);
98+
if (!isDate && (typeof v === 'object')) {
99+
cell.s = v.style;
100+
cell.v = v.value;
101+
v = v.value;
102+
}
103+
94104
if (typeof v === 'number') {
95-
cell.v = v;
96105
cell.t = 'n';
97106
} else if (typeof v === 'boolean') {
98-
cell.v = v;
99107
cell.t = 'b';
100-
} else if (v instanceof Date) {
108+
} else if (isDate) {
101109
cell.t = 'n';
102110
cell.z = XLSX.SSF._table[14];
103111
cell.v = dateToNumber(cell.v);
104-
} else if (typeof v === 'object') {
105-
cell.v = v.value;
106-
cell.s = v.style;
107112
} else {
108-
cell.v = v;
109113
cell.t = 's';
110114
}
111115
ws[cellRef] = cell;

0 commit comments

Comments
 (0)