From 7920096dc912f2b4c1226dab864a0af1c0cb8bdb Mon Sep 17 00:00:00 2001 From: Abhishekk Handa Date: Sun, 24 Feb 2019 15:07:07 +0700 Subject: [PATCH] fix for displayName if headerStyle missing --- index.js | 2 +- lib/excel.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index add82d6..c142f9d 100755 --- a/index.js +++ b/index.js @@ -29,7 +29,7 @@ let buildExport = params => { for (let col in specification) { header.push({ value: specification[col].displayName, - style: specification[col].headerStyle || '' + style: specification[col].headerStyle }) if (specification[col].width) { diff --git a/lib/excel.js b/lib/excel.js index d2706d1..dba485c 100755 --- a/lib/excel.js +++ b/lib/excel.js @@ -19,11 +19,13 @@ function sheet_from_array_of_arrays(data, merges) { if(range.e.c < C) range.e.c = C; let cell; - if(data[R][C] && typeof data[R][C] === 'object' && data[R][C].style && !(data[R][C] instanceof Date)) { + if(data[R][C] && typeof data[R][C] === 'object' && !(data[R][C] instanceof Date)) { cell = { v: data[R][C].value, - s: data[R][C].style }; + if (data[R][C].style) { + cell.s = data[R][C].style + } } else { cell = {v: data[R][C] }; }