From 513ae48548ba1b8150cc2ba1e461a9cee8ba50a1 Mon Sep 17 00:00:00 2001 From: Boaz Adato Date: Wed, 16 May 2018 11:26:55 +0300 Subject: [PATCH] fix: int cells were not supported in dataSet format --- dist/ExcelPlugin/utils/DataUtil.js | 19 +++++++++++-------- src/ExcelPlugin/utils/DataUtil.js | 20 ++++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/dist/ExcelPlugin/utils/DataUtil.js b/dist/ExcelPlugin/utils/DataUtil.js index 0c9211fd..e01f3d55 100644 --- a/dist/ExcelPlugin/utils/DataUtil.js +++ b/dist/ExcelPlugin/utils/DataUtil.js @@ -100,25 +100,28 @@ function getHeaderCell(v, cellRef, ws) { } function getCell(v, cellRef, ws) { - var cell = {}; + //assume v is indeed the value. for other cases (object, date...) it will be overriden. + var cell = { v: v }; if (v === null) { return; } + + var isDate = v instanceof Date; + if (!isDate && (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object') { + cell.s = v.style; + cell.v = v.value; + v = v.value; + } + if (typeof v === 'number') { - cell.v = v; cell.t = 'n'; } else if (typeof v === 'boolean') { - cell.v = v; cell.t = 'b'; - } else if (v instanceof Date) { + } else if (isDate) { cell.t = 'n'; cell.z = _xlsx2.default.SSF._table[14]; cell.v = dateToNumber(cell.v); - } else if ((typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object') { - cell.v = v.value; - cell.s = v.style; } else { - cell.v = v; cell.t = 's'; } ws[cellRef] = cell; diff --git a/src/ExcelPlugin/utils/DataUtil.js b/src/ExcelPlugin/utils/DataUtil.js index 13f6b110..0b332adf 100644 --- a/src/ExcelPlugin/utils/DataUtil.js +++ b/src/ExcelPlugin/utils/DataUtil.js @@ -87,25 +87,29 @@ function getHeaderCell(v, cellRef, ws) { } function getCell(v, cellRef, ws) { - var cell = {}; + //assume v is indeed the value. for other cases (object, date...) it will be overriden. + var cell = {v}; if (v === null) { return; } + + + var isDate = (v instanceof Date); + if (!isDate && (typeof v === 'object')) { + cell.s = v.style; + cell.v = v.value; + v = v.value; + } + if (typeof v === 'number') { - cell.v = v; cell.t = 'n'; } else if (typeof v === 'boolean') { - cell.v = v; cell.t = 'b'; - } else if (v instanceof Date) { + } else if (isDate) { cell.t = 'n'; cell.z = XLSX.SSF._table[14]; cell.v = dateToNumber(cell.v); - } else if (typeof v === 'object') { - cell.v = v.value; - cell.s = v.style; } else { - cell.v = v; cell.t = 's'; } ws[cellRef] = cell;