Skip to content

Commit d65eeb3

Browse files
Merge pull request #53 from boazadato/fix-int-cells-in-dataSet
fix: int cells were not supported in dataSet format
2 parents 7c0baae + 064f1e4 commit d65eeb3

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

dist/ExcelPlugin/utils/DataUtil.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,28 @@ function getHeaderCell(v, cellRef, ws) {
110110
}
111111

112112
function getCell(v, cellRef, ws) {
113-
var cell = {};
113+
//assume v is indeed the value. for other cases (object, date...) it will be overriden.
114+
var cell = { v: v };
114115
if (v === null) {
115116
return;
116117
}
118+
119+
var isDate = v instanceof Date;
120+
if (!isDate && (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object') {
121+
cell.s = v.style;
122+
cell.v = v.value;
123+
v = v.value;
124+
}
125+
117126
if (typeof v === 'number') {
118-
cell.v = v;
119127
cell.t = 'n';
120128
} else if (typeof v === 'boolean') {
121-
cell.v = v;
122129
cell.t = 'b';
123-
} else if (v instanceof Date) {
130+
} else if (isDate) {
124131
cell.t = 'n';
125132
cell.z = _xlsx2.default.SSF._table[14];
126133
cell.v = dateToNumber(cell.v);
127-
} else if ((typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object') {
128-
cell.v = v.value;
129-
cell.s = v.style;
130134
} else {
131-
cell.v = v;
132135
cell.t = 's';
133136
}
134137
ws[cellRef] = cell;

src/ExcelPlugin/utils/DataUtil.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,29 @@ function getHeaderCell(v, cellRef, ws) {
9797
}
9898

9999
function getCell(v, cellRef, ws) {
100-
var cell = {};
100+
//assume v is indeed the value. for other cases (object, date...) it will be overriden.
101+
var cell = {v};
101102
if (v === null) {
102103
return;
103104
}
105+
106+
107+
var isDate = (v instanceof Date);
108+
if (!isDate && (typeof v === 'object')) {
109+
cell.s = v.style;
110+
cell.v = v.value;
111+
v = v.value;
112+
}
113+
104114
if (typeof v === 'number') {
105-
cell.v = v;
106115
cell.t = 'n';
107116
} else if (typeof v === 'boolean') {
108-
cell.v = v;
109117
cell.t = 'b';
110-
} else if (v instanceof Date) {
118+
} else if (isDate) {
111119
cell.t = 'n';
112120
cell.z = XLSX.SSF._table[14];
113121
cell.v = dateToNumber(cell.v);
114-
} else if (typeof v === 'object') {
115-
cell.v = v.value;
116-
cell.s = v.style;
117122
} else {
118-
cell.v = v;
119123
cell.t = 's';
120124
}
121125
ws[cellRef] = cell;

0 commit comments

Comments
 (0)