From 6688ffca697e56c982234d75c9c6305ec0ae4272 Mon Sep 17 00:00:00 2001 From: Rango Yuan Date: Wed, 9 Dec 2020 10:11:49 +0000 Subject: [PATCH] enhance cell customization - add data-base64-xlsx-cell-config --- src/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/index.js b/src/index.js index a66981b..c5b7952 100644 --- a/src/index.js +++ b/src/index.js @@ -136,6 +136,19 @@ module.exports = (html, callback, options = {}) => { cell.hMerge = cs - 1; } + // In case you need the flexibility to config all possible + // _value, formula, numFmt, cellType... + const dataBase64CellConfig = $td.attr('data-base64-xlsx-cell-config'); + if (dataBase64CellConfig) { + try { + const configString = Buffer.from(dataBase64CellConfig, 'base64').toString('utf-8'); + Object.assign(cell, JSON.parse(configString)); + } catch (e) { + console.error(configString); + console.error(e); + } + } + for (let r = 0; r < rs; r++) { if (offsets[hi + r] === undefined) { offsets[hi + r] = 0;