diff --git a/API.md b/API.md index 718148c..9475abe 100644 --- a/API.md +++ b/API.md @@ -36,14 +36,14 @@ Constructs a new instance of XlsxDataFill with given options. | --- | --- | --- | | accessor | object | An instance of XLSX spreadsheet accessing class. | | opts | Object | Options to be used during processing. | -| opts.templateRegExp | RegExp | The regular expression to be used for template recognizing. Default is `/\{\{([^}]*)\}\}/`, i.e. Mustache. | -| opts.fieldSplitter | string | The string to be expected as template field splitter. Default is `|`. | -| opts.joinText | string | The string to be used when the extracted value for a single cell is an array, and it needs to be joined. Default is `,`. | -| opts.mergeCells | string \| boolean | Whether to merge the higher dimension cells in the output. Default is true. | -| opts.duplicateCells | string \| boolean | Whether to duplicate the content of higher dimension cells, when not merged. Default is false. | +| opts.templateRegExp | RegExp | The regular expression to be used for template recognizing. Default is `/\{\{([^}]*)\}\}/`, i.e. Mustache. | +| opts.fieldSplitter | string \| RegExo | The string or regular expression to be used as template fields splitter. Default is `|`. | +| opts.joinText | string | The string to be used when the extracted value for a single cell is an array, and it needs to be joined. Default is `,`. | +| opts.mergeCells | string \| boolean | Whether to merge the higher dimension cells in the output. Default is true, but valid values are also `"both"`, `"vertical"` and `"horizontal"`. | +| opts.duplicateCells | string \| boolean | Whether to duplicate the content of higher dimension cells, when not merged. Default is false. Same valud values as `mergeCells`. | | opts.followFormulae | boolean | If a template is located as a result of a formula, whether to still process it. Default is false. | | opts.copyStyle | boolean | Copy the style of the template cell when populating. Even when `false`, the template styling _is_ applied. Default is true. | -| opts.callbacksMap | object.<string, function()> | A map of handlers to be used for data and value extraction. There is one default - the empty one, for object key extraction. | +| opts.callbacksMap | object.<string, function()> | A map of handlers to be used for data and value extraction. | @@ -52,11 +52,10 @@ Setter/getter for XlsxDataFill's options as set during construction. **Kind**: instance method of [XlsxDataFill](#XlsxDataFill) **Returns**: [XlsxDataFill](#XlsxDataFill) \| Object - The required options (in getter mode) or XlsxDataFill (in setter mode) for chaining. -**See**: {@constructor}. | Param | Type | Description | | --- | --- | --- | -| newOpts | Object \| null | If set - the new options to be used. | +| newOpts | Object \| null | If set - the new options to be used. Check [up here](#new-xlsxdatafillaccessor-opts). | diff --git a/README.md b/README.md index 6be3b3f..3ec1a30 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ Here are the options and their defaults. { templateRegExp: new RegExp(/\{\{([^}]*)\}\}/), fieldSplitter: "|", - joinText: ",", + joinText: ",", mergeCells: true, duplicateCells: false, followFormulae: false, @@ -207,6 +207,22 @@ Here are the options and their defaults. ``` +Check the [detailed description in the API](API.md#new-xlsxdatafillaccessor-opts). It is worth noting the `mergeCells` and `duplicateCells` behavior. + +First, they both have the same set of possible values: `true`, `false`, `”both”`, `”vertical”`, `”horizontal”` – in which direction the cells need to be merged/duplicated. As expected `true` and `”both”` have the same meaning. + +Second, cells duplication is valid only when merging is disabled, in other words, if `mergeCells == true`, `duplicateCells` is ignored. Given these options: + +```js +mergeCells: "vertical", +duplicateCells: true +``` + +Is interpreted as follow: + +* If during data expansion a value in higher dimension occupies more than one cell in a **column**, they are merged – because these are _vertical_. +* If a value from higher dimension occupies more than one cell in a **row**, then duplication options is taken into account and same value is duplicated on all these cells. + ## Formulae handling As formulas are a key Excel feature, so `xlsx-datafill` is trying to keep them alive and meaningful. As a basic rule _Raw formulas are kept as they are, only those put in a template format, are handled_. diff --git a/browser/xlsx-datafill.js b/browser/xlsx-datafill.js index 854814e..ead35a3 100644 --- a/browser/xlsx-datafill.js +++ b/browser/xlsx-datafill.js @@ -51,19 +51,14 @@ var XlsxDataFill = /*#__PURE__*/function () { * Constructs a new instance of XlsxDataFill with given options. * @param {object} accessor An instance of XLSX spreadsheet accessing class. * @param {{}} opts Options to be used during processing. - * @param {RegExp} opts.templateRegExp The regular expression to be used for template recognizing. - * Default is `/\{\{([^}]*)\}\}/`, i.e. Mustache. - * @param {string} opts.fieldSplitter The string to be expected as template field splitter. Default is `|`. - * @param {string} opts.joinText The string to be used when the extracted value for a single cell is an array, - * and it needs to be joined. Default is `,`. - * @param {string|boolean} opts.mergeCells Whether to merge the higher dimension cells in the output. Default is true. - * @param {string|boolean} opts.duplicateCells Whether to duplicate the content of higher dimension cells, when not merged. Default is false. - * @param {boolean} opts.followFormulae If a template is located as a result of a formula, whether to still process it. - * Default is false. - * @param {boolean} opts.copyStyle Copy the style of the template cell when populating. Even when `false`, the template - * styling _is_ applied. Default is true. + * @param {RegExp} opts.templateRegExp The regular expression to be used for template recognizing. Default is `/\{\{([^}]*)\}\}/`, i.e. Mustache. + * @param {string|RegExo} opts.fieldSplitter The string or regular expression to be used as template fields splitter. Default is `|`. + * @param {string} opts.joinText The string to be used when the extracted value for a single cell is an array, and it needs to be joined. Default is `,`. + * @param {string|boolean} opts.mergeCells Whether to merge the higher dimension cells in the output. Default is true, but valid values are also `"both"`, `"vertical"` and `"horizontal"`. + * @param {string|boolean} opts.duplicateCells Whether to duplicate the content of higher dimension cells, when not merged. Default is false. Same valud values as `mergeCells`. + * @param {boolean} opts.followFormulae If a template is located as a result of a formula, whether to still process it. Default is false. + * @param {boolean} opts.copyStyle Copy the style of the template cell when populating. Even when `false`, the template styling _is_ applied. Default is true. * @param {object.} opts.callbacksMap A map of handlers to be used for data and value extraction. - * There is one default - the empty one, for object key extraction. */ function XlsxDataFill(accessor, opts) { _classCallCheck(this, XlsxDataFill); @@ -75,8 +70,7 @@ var XlsxDataFill = /*#__PURE__*/function () { } /** * Setter/getter for XlsxDataFill's options as set during construction. - * @param {{}|null} newOpts If set - the new options to be used. - * @see {@constructor}. + * @param {{}|null} newOpts If set - the new options to be used. Check [up here]{@link #new-xlsxdatafillaccessor-opts}. * @returns {XlsxDataFill|{}} The required options (in getter mode) or XlsxDataFill (in setter mode) for chaining. */ @@ -954,4 +948,4 @@ module.exports = XlsxPopulateAccess; },{}]},{},[1])(1) }); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuan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20uXG4gICAgICogQHBhcmFtIHt7fX0gZGF0YSBUaGUgZGF0YSB0byBiZSBhcHBsaWVkLlxuICAgICAqIEByZXR1cm5zIHtYbHN4RGF0YUZpbGx9IEZvciBpbnZvY2F0aW9uIGNoYWluaW5nLlxuICAgICAqL1xuICAgIGZpbGxEYXRhKGRhdGEpIHtcbiAgICAgICAgY29uc3QgZGF0YUZpbGxzID0ge307XG5cdFxuICAgICAgICAvLyBCdWlsZCB0aGUgZGVwZW5kZW5jeSBjb25uZWN0aW9ucyBiZXR3ZWVuIHRlbXBsYXRlcy5cbiAgICAgICAgdGhpcy5jb2xsZWN0VGVtcGxhdGVzKHRlbXBsYXRlID0+IHtcbiAgICAgICAgICAgIGNvbnN0IGFGaWxsID0geyAgXG4gICAgICAgICAgICAgICAgdGVtcGxhdGU6IHRlbXBsYXRlLCBcbiAgICAgICAgICAgICAgICBkZXBlbmRlbnRzOiBbXSxcbiAgICAgICAgICAgICAgICBmb3JtdWxhczogW10sXG4gICAgICAgICAgICAgICAgcHJvY2Vzc2VkOiBmYWxzZVxuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgaWYgKHRlbXBsYXRlLnJlZmVyZW5jZSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IHJlZkZpbGwgPSBkYXRhRmlsbHNbdGVtcGxhdGUucmVmZXJlbmNlXTtcbiAgICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgICBpZiAoIXJlZkZpbGwpIFxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYFVuYWJsZSB0byBmaW5kIGEgcmVmZXJlbmNlICcke3RlbXBsYXRlLnJlZmVyZW5jZX0nIWApO1xuICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgIGlmICh0ZW1wbGF0ZS5mb3JtdWxhKSBcbiAgICAgICAgICAgICAgICAgICAgcmVmRmlsbC5mb3JtdWxhcy5wdXNoKGFGaWxsKTtcbiAgICAgICAgICAgICAgICBlbHNlXG4gICA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lbnRzIG9mIHRoZSB0ZW1wbGF0ZSAnJHtyZU1hdGNoWzBdfSdgKTtcbiAgICAgICAgaWYgKCEhcGFydHNbMF0gJiYgIWNlbGxSZWYpXG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYEludmFsaWQgcmVmZXJlbmNlIHBhc3NlZDogJyR7cGFydHNbMF19J2ApO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBpZDogdGhpcy5fYWNjZXNzLmNlbGxSZWYoY2VsbCksXG4gICAgICAgICAgICByZWZlcmVuY2U6IGNlbGxSZWYsXG4gICAgICAgICAgICBpdGVyYXRvcnM6IHBhcnRzWzFdLnNwbGl0KC94fFxcKi8pLm1hcChfLnRyaW0pLFxuICAgICAgICAgICAgZXh0cmFjdG9yOiBleHRyYWN0b3IsXG4gICAgICAgICAgICBmb3JtdWxhOiBleHRyYWN0b3Iuc3RhcnRzV2l0aChcIj1cIiksXG4gICAgICAgICAgICBjZWxsOiBjZWxsLFxuICAgICAgICAgICAgY2VsbFNpemU6IHRoaXMuX2FjY2Vzcy5jZWxsU2l6ZShjZWxsKSxcbiAgICAgICAgICAgIHBhZGRpbmc6IChwYXJ0c1szXSB8fCBcIlwiKS5zcGxpdCgvOnwsfHh8XFwqLykubWFwKHYgPT4gcGFyc2VJbnQodikgfHwgMCksXG4gICAgICAgICAgICBzdHlsZXM6ICFzdHlsZXMgPyBudWxsIDogXy5tYXAoc3R5bGVzLCBzID0+IHtcbiAgICAgICAgICAgICAgICBjb25zdCBwYWlyID0gXy50cmltKHMpLnNwbGl0KFwiPVwiKTtcbiAgICAgICAgICAgICAgICByZXR1cm4geyBuYW1lOiBfLnRyaW0ocGFpclswXSksIGV4dHJhY3RvcjogXy50cmltKHBhaXJbMV0pIH07XG4gICAgICAgICAgICB9KVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIHNvcnRUZW1wbGF0ZXMobGlzdCkge1xuICAgICAgICBjb25zdCBzb3J0ZWQgPSBbXSxcbiAgICAgICAgICAgIHJlbGF0ZWQgPSB7fSxcbiAgICAgICAgICAgIG1hcCA9IHt9LFxuICAgICAgICAgICAgZnJlZUxpc3QgPSBbXTtcblxuICAgICAgICAvLyBGaXJzdCwgbWFrZSB0aGUgZGVwZW5kZW5jeSBtYXAgYW5kIGFkZCB0aGUgbGlzdCBvZiBub24tcmVmZXJlbmNpbmcgdGVtcGxhdGVzXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgY29uc3QgdCA9IGxpc3RbaV07XG4gICAgICAgICAgICBtYXBbdC5pZF0gPSBpO1xuXG4gICAgICAgICAgICBpZiAoIXQucmVmZXJlbmNlKVxuICAgICAgICAgICAgICAgIGZyZWVMaXN0LnB1c2godC5pZCk7XG4gICAgICAgICAgICBlbHNlIFxuICAgICAgICAgICAgICAgIChyZWxhdGVkW3QucmVmZXJlbmNlXSA9IHJlbGF0ZWRbdC5yZWZlcmVuY2VdIHx8IFtdKS5wdXNoKHQuaWQpO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gTm93LCBtYWtlIHRoZSBhY3R1YWwgc29ydGluZy5cbiAgICAgICAgd2hpbGUgKGZyZWVMaXN0Lmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIGNvbnN0IGlkID0gZnJlZUxpc3Quc2hpZnQoKSxcbiAgICAgICAgICAgICAgICB0ID0gbGlzdFttYXBbaWRdXTtcblxuICAgICAgICAgICAgc29ydGVkLnB1c2godCk7XG4gICAgICAgICAgICBcbiAgICAgICAgICAgIC8vIFdlIHVzZSB0aGUgZmFjdCB0aGF0IHRoZXJlIGlzIGEgc2luZ2xlIHByZWRlY2Vzc29yIGluIG91ciBzZXR1cC5cbiAgICAgICAgICAgIGlmIChyZWxhdGVkW3QuaWRdKVxuICAgICAgICAgICAgICAgIGZyZWVMaXN0LnB1c2goLi4ucmVsYXRlZFt0LmlkXSk7XG4gICAgICAgIH1cblxuICAgICAg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ICAgICAgICBfLmZvckVhY2godGhpcy5wdXRWYWx1ZXMobmV4dENlbGwsIGluUm9vdCwgdGVtcGxhdGUpLCBzaXplTWF4eGVyKTtcblxuICAgICAgICAgICAgICAgIGxldCByb3dPZmZzZXQgPSBlbnRyeVNpemVbMF0sXG4gICAgICAgICAgICAgICAgICAgIGNvbE9mZnNldCA9IGVudHJ5U2l6ZVsxXSxcbiAgICAgICAgICAgICAgICAgICAgcm93UGFkZGluZyA9IHRlbXBsYXRlLnBhZGRpbmdbMF0gfHwgMCxcbiAgICAgICAgICAgICAgICAgICAgY29sUGFkZGluZyA9IHRlbXBsYXRlLnBhZGRpbmdbMV0gfHwgMDtcblxuICAgICAgICAgICAgICAgIC8vIE1ha2Ugc3VyZSB3ZSBncm93IG9ubHkgb24gb25lIGRpbWVuc2lvbi5cbiAgICAgICAgICAgICAgICBpZiAodGhlRGF0YS5zaXplc1swXSA8IDApIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRlbXBsYXRlLnBhZGRpbmcubGVuZ3RoIDwgMilcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbFBhZGRpbmcgPSByb3dQYWRkaW5nO1xuICAgICAgICAgICAgICAgICAgICByb3dPZmZzZXQgPSByb3dQYWRkaW5nID0gMDtcbiAgICAgICAgICAgICAgICAgICAgZW50cnlTaXplWzFdID0gMTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoZURhdGEuc2l6ZXMubGVuZ3RoIDwgMikge1xuICAgICAgICAgICAgICAgICAgICBjb2xPZmZzZXQgPSBjb2xQYWRkaW5nID0gMDtcbiAgICAgICAgICAgICAgICAgICAgZW50cnlTaXplWzBdID0gMTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAocm93T2Zmc2V0ID4gMSB8fCBjb2xPZmZzZXQgPiAxKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJuZyA9IHRoaXMuX2FjY2Vzcy5nZXRDZWxsUmFuZ2UobmV4dENlbGwsIE1hdGgubWF4KHJvd09mZnNldCAtIDEsIDApLCBNYXRoLm1heChjb2xPZmZzZXQgLSAxLCAwKSksXG4gICAgICAgICAgICAgICAgICAgICAgICBfb3B0cyA9IHRoaXMuZ2V0VGVtcGxhdGVPcHRzKHRlbXBsYXRlKTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAoX29wdHMubWVyZ2VDZWxscyA9PT0gdHJ1ZSB8fCBfb3B0cy5tZXJnZUNlbGwgPT09ICdib3RoJ1xuICAgICAgICAgICAgICAgICAgICAgICAgfHwgcm93T2Zmc2V0ID4gMSAmJiBfb3B0cy5tZXJnZUNlbGxzID09PSAndmVydGljYWwnIFxuICAgICAgICAgICAgICAgICAgICAgICAgfHwgY29sT2Zmc2V0ID4gMSAmJiBfb3B0cy5tZXJnZUNlbGxzID09PSAnaG9yaXpvbnRhbCcpXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hY2Nlc3MucmFuZ2VNZXJnZWQocm5nLCB0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgZWxzZSBpZiAoX29wdHMuZHVwbGljYXRlQ2VsbHMgPT09IHRydWUgfHwgX29wdHMuZHVwbGljYXRlQ2VsbHMgPT09ICdib3RoJ1xuICAgICAgICAgICAgICAgICAgICAgICAgfHwgcm93T2Zmc2V0ID4gMSAmJiBfb3B0cy5kdXBsaWNhdGVDZWxscyA9PT0gJ3ZlcnRpY2FsJyBcbiAgICAgICAgICAgICAgICAgICAgICAgIHx8IGNvbE9mZnNldCA+IDEgJiYgX29wdHMuZHVwbGljYXRlQ2VsbHMgPT09ICdob3Jpem9udGFsJylcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2FjY2Vzcy5kdXBsaWNhdGVDZWxsKG5leHRDZWxsLCBybmcpO1xuXG4gICAgICAgICAgICAgICAgICAgIHJuZy5mb3JFYWNoKGNlbGwgPT4gdGhpcy5hcHBseURhdGFTdHlsZShjZWxsLCBpblJvb3QsIHR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N0JyBmb3IgY29weVN0eWxlKCkhXCIpO1xuICAgICAgICBpZiAoc3JjID09IGRlc3QpIHJldHVybiB0aGlzO1xuXG4gICAgICAgIGlmIChzcmMuX3N0eWxlICE9PSB1bmRlZmluZWQpXG4gICAgICAgICAgICBkZXN0LnN0eWxlKHNyYy5fc3R5bGUpO1xuICAgICAgICBlbHNlIGlmIChzcmMuX3N0eWxlSWQgPiAwKVxuICAgICAgICAgICAgZGVzdC5fc3R5bGVJZCA9IHNyYy5fc3R5bGVJZDtcblxuICAgICAgICBjb25zdCBkZXN0U2hlZXRJZCA9IGRlc3Quc2hlZXQoKS5uYW1lKCksXG4gICAgICAgICAgICByb3dJZCA9IGAnJHtkZXN0U2hlZXRJZH0nOiR7ZGVzdC5yb3dOdW1iZXIoKX1gLFxuICAgICAgICAgICAgY29sSWQgPSBgJyR7ZGVzdFNoZWV0SWR9Jzoke2Rlc3QuY29sdW1uTnVtYmVyKCl9YDtcblxuICAgICAgICBpZiAodGhpcy5fcm93U2l6ZXNbcm93SWRdID09PSB1bmRlZmluZWQpXG4gICAgICAgICAgICBkZXN0LnJvdygpLmhlaWdodCh0aGlzLl9yb3dTaXplc1tyb3dJZF0gPSBzcmMucm93KCkuaGVpZ2h0KCkpO1xuICAgICAgICBcbiAgICAgICAgaWYgKHRoaXMuX2NvbFNpemVzW2NvbElkXSA9PT0gdW5kZWZpbmVkKVxuICAgICAgICAgICAgZGVzdC5jb2x1bW4oKS53aWR0aCh0aGlzLl9jb2xTaXplc1tjb2xJZF0gPSBzcmMuY29sdW1uKCkud2lkdGgoKSk7XG5cbiAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgfVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IFhsc3hQb3B1bGF0ZUFjY2VzcztcbiJdfQ== +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZG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vbGUgZGF0YSBwb3B1bGF0aW9uIG1lY2hhbmlzbS5cbiAgICAgKiBAcGFyYW0ge3t9fSBkYXRhIFRoZSBkYXRhIHRvIGJlIGFwcGxpZWQuXG4gICAgICogQHJldHVybnMge1hsc3hEYXRhRmlsbH0gRm9yIGludm9jYXRpb24gY2hhaW5pbmcuXG4gICAgICovXG4gICAgZmlsbERhdGEoZGF0YSkge1xuICAgICAgICBjb25zdCBkYXRhRmlsbHMgPSB7fTtcblx0XG4gICAgICAgIC8vIEJ1aWxkIHRoZSBkZXBlbmRlbmN5IGNvbm5lY3Rpb25zIGJldHdlZW4gdGVtcGxhdGVzLlxuICAgICAgICB0aGlzLmNvbGxlY3RUZW1wbGF0ZXModGVtcGxhdGUgPT4ge1xuICAgICAgICAgICAgY29uc3QgYUZpbGwgPSB7ICBcbiAgICAgICAgICAgICAgICB0ZW1wbGF0ZTogdGVtcGxhdGUsIFxuICAgICAgICAgICAgICAgIGRlcGVuZGVudHM6IFtdLFxuICAgICAgICAgICAgICAgIGZvcm11bGFzOiBbXSxcbiAgICAgICAgICAgICAgICBwcm9jZXNzZWQ6IGZhbHNlXG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICBpZiAodGVtcGxhdGUucmVmZXJlbmNlKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgcmVmRmlsbCA9IGRhdGFGaWxsc1t0ZW1wbGF0ZS5yZWZlcmVuY2VdO1xuICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgIGlmICghcmVmRmlsbCkgXG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5hYmxlIHRvIGZpbmQgYSByZWZlcmVuY2UgJyR7dGVtcGxhdGUucmVmZXJlbmNlfSchYCk7XG4gICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgaWYgKHRlbXBsYXRlLmZvcm11bGEpIFxuICAgICAgICAgICAgICAgICAgICByZWZGaWxsLmZvcm11bGFzLnB1c2goYUZpbGwpO1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ICAgIF8uZm9yRWFjaCh0aGlzLnB1dFZhbHVlcyhuZXh0Q2VsbCwgaW5Sb290LCB0ZW1wbGF0ZSksIHNpemVNYXh4ZXIpO1xuXG4gICAgICAgICAgICAgICAgbGV0IHJvd09mZnNldCA9IGVudHJ5U2l6ZVswXSxcbiAgICAgICAgICAgICAgICAgICAgY29sT2Zmc2V0ID0gZW50cnlTaXplWzFdLFxuICAgICAgICAgICAgICAgICAgICByb3dQYWRkaW5nID0gdGVtcGxhdGUucGFkZGluZ1swXSB8fCAwLFxuICAgICAgICAgICAgICAgICAgICBjb2xQYWRkaW5nID0gdGVtcGxhdGUucGFkZGluZ1sxXSB8fCAwO1xuXG4gICAgICAgICAgICAgICAgLy8gTWFrZSBzdXJlIHdlIGdyb3cgb25seSBvbiBvbmUgZGltZW5zaW9uLlxuICAgICAgICAgICAgICAgIGlmICh0aGVEYXRhLnNpemVzWzBdIDwgMCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodGVtcGxhdGUucGFkZGluZy5sZW5ndGggPCAyKVxuICAgICAgICAgICAgICAgICAgICAgICAgY29sUGFkZGluZyA9IHJvd1BhZGRpbmc7XG4gICAgICAgICAgICAgICAgICAgIHJvd09mZnNldCA9IHJvd1BhZGRpbmcgPSAwO1xuICAgICAgICAgICAgICAgICAgICBlbnRyeVNpemVbMV0gPSAxO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhlRGF0YS5zaXplcy5sZW5ndGggPCAyKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbE9mZnNldCA9IGNvbFBhZGRpbmcgPSAwO1xuICAgICAgICAgICAgICAgICAgICBlbnRyeVNpemVbMF0gPSAxO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChyb3dPZmZzZXQgPiAxIHx8IGNvbE9mZnNldCA+IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgcm5nID0gdGhpcy5fYWNjZXNzLmdldENlbGxSYW5nZShuZX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cIik7XG4gICAgICAgIGlmIChzcmMgPT0gZGVzdCkgcmV0dXJuIHRoaXM7XG5cbiAgICAgICAgaWYgKHNyYy5fc3R5bGUgIT09IHVuZGVmaW5lZClcbiAgICAgICAgICAgIGRlc3Quc3R5bGUoc3JjLl9zdHlsZSk7XG4gICAgICAgIGVsc2UgaWYgKHNyYy5fc3R5bGVJZCA+IDApXG4gICAgICAgICAgICBkZXN0Ll9zdHlsZUlkID0gc3JjLl9zdHlsZUlkO1xuXG4gICAgICAgIGNvbnN0IGRlc3RTaGVldElkID0gZGVzdC5zaGVldCgpLm5hbWUoKSxcbiAgICAgICAgICAgIHJvd0lkID0gYCcke2Rlc3RTaGVldElkfSc6JHtkZXN0LnJvd051bWJlcigpfWAsXG4gICAgICAgICAgICBjb2xJZCA9IGAnJHtkZXN0U2hlZXRJZH0nOiR7ZGVzdC5jb2x1bW5OdW1iZXIoKX1gO1xuXG4gICAgICAgIGlmICh0aGlzLl9yb3dTaXplc1tyb3dJZF0gPT09IHVuZGVmaW5lZClcbiAgICAgICAgICAgIGRlc3Qucm93KCkuaGVpZ2h0KHRoaXMuX3Jvd1NpemVzW3Jvd0lkXSA9IHNyYy5yb3coKS5oZWlnaHQoKSk7XG4gICAgICAgIFxuICAgICAgICBpZiAodGhpcy5fY29sU2l6ZXNbY29sSWRdID09PSB1bmRlZmluZWQpXG4gICAgICAgICAgICBkZXN0LmNvbHVtbigpLndpZHRoKHRoaXMuX2NvbFNpemVzW2NvbElkXSA9IHNyYy5jb2x1bW4oKS53aWR0aCgpKTtcblxuICAgICAgICByZXR1cm4gdGhpcztcbiAgICB9XG59XG5cbm1vZHVsZS5leHBvcnRzID0gWGxzeFBvcHVsYXRlQWNjZXNzO1xuIl19 diff --git a/browser/xlsx-datafill.min.js.map b/browser/xlsx-datafill.min.js.map index a905f98..ef7feb9 100644 --- a/browser/xlsx-datafill.min.js.map +++ b/browser/xlsx-datafill.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["node_modules/browser-pack/_prelude.js","src/XlsxDataFill.js","src/XlsxPopulateAccess.js"],"names":["f","exports","module","define","amd","window","global","self","this","XlsxDataFill","r","e","n","t","o","i","c","require","u","a","Error","code","p","call","length","1","_2","defaultOpts","templateRegExp","fieldSplitter","joinText","mergeCells","duplicateCells","followFormulae","copyStyle","callbacksMap","","data","keys","$","values","refRegExp","accessor","opts","_classCallCheck","_opts","defaultsDeep","_rowSizes","_colSizes","_access","newOpts","merge","_this","dataFills","collectTemplates","template","aFill","dependents","formulas","processed","reference","refFill","concat","formula","push","offset","cellDistance","cell","id","each","fill","extractor","applyFill","handlerName","handlerFn","extractParts","split","trim","path","handler","getHandler","_this2","styles","pair","startsWith","name","substr","val","extractValues","setCellStyle","JSON","parse","clone","value","cellValue","reMatch","match","cellType","parts","map","cellRef","buildRef","iterators","cellSize","padding","v","parseInt","s","list","sorted","related","freeList","_t","shift","apply","_toConsumableArray","xor","join","cb","_this3","allTemplates","forAllCells","parseTemplate","sortTemplates","forEach","root","_this4","_this$parseExtractor","parseExtractor","Array","isArray","undefined","sizes","entry","get","idx","_this5","iter","transposed","parsedIter","_typeof","inRoot","extractData","unshift","_this6","entrySize","chunk","getCellRange","ri","ci","setCellValue","applyDataStyle","mainCell","_this7","theData","nextCell","sizeMaxxer","Math","max","_loop","d","inFill","inCell","offsetCell","putValues","rowOffset","colOffset","rowPadding","colPadding","rng","getTemplateOpts","mergeCell","rangeMerged","duplicateCell","applyFormula","size","newFormula","newRef","from","getCell","rangeRef","index","shiftFormula","setCellFormula","setRangeFormula","XlsxPopulateAccess","version","_","_RichText","workbook","XlsxPopulate","_workbook","RichText","theValue","text","hyperlink","Date","trimStart","to","rowNumber","columnNumber","cellAddr","address","theSize","sheet","_mergeCells","range","rangeAddr","attributes","ref","style","withSheet","includeSheetName","adr","sheetId","activeSheet","rangeTo","relativeCell","rows","cols","status","merged","sheets","theRange","usedRange","dest","src","_style","_styleId","destSheetId","rowId","colId","row","height","column","width"],"mappings":"CAAA,SAAAA,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M,MAAM,gDACnC,GAAI8M,GAAOD,EAAM,OAAOzN,UAEL2H,IAAf+F,EAAIC,OACJF,EAAKf,MAAMgB,EAAIC,QACVD,EAAIE,SAAW,IACpBH,EAAKG,SAAWF,EAAIE,UAExB,IAAMC,EAAcJ,EAAKrB,QAAQvH,OAC7BiJ,EAAK,IAAAxK,OAAOuK,EAAP,MAAAvK,OAAuBmK,EAAK1B,aACjCgC,EAAK,IAAAzK,OAAOuK,EAAP,MAAAvK,OAAuBmK,EAAKzB,gBAQrC,YAN8BrE,IAA1B3H,KAAKuC,UAAUuL,IACfL,EAAKO,MAAMC,OAAOjO,KAAKuC,UAAUuL,GAASJ,EAAIM,MAAMC,eAE1BtG,IAA1B3H,KAAKwC,UAAUuL,IACfN,EAAKS,SAASC,MAAMnO,KAAKwC,UAAUuL,GAASL,EAAIQ,SAASC,SAEtDnO,0CAIfN,EAAOD,QAAUwL,iIFjUjB","file":"xlsx-datafill.min.js","sourcesContent":["(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i _.keys(data),\n $: data => _.values(data)\n }\n};\n\nconst refRegExp = /('?([^!]*)?'?!)?([A-Z]+\\d+)(:([A-Z]+\\d+))?/;\n\n/**\n * Data fill engine, taking an instance of Excel sheet accessor and a JSON object as data, and filling the values from the latter into the former.\n */\nclass XlsxDataFill {\n /**\n * Constructs a new instance of XlsxDataFill with given options.\n * @param {object} accessor An instance of XLSX spreadsheet accessing class.\n * @param {{}} opts Options to be used during processing.\n * @param {RegExp} opts.templateRegExp The regular expression to be used for template recognizing. \n * Default is `/\\{\\{([^}]*)\\}\\}/`, i.e. Mustache.\n * @param {string} opts.fieldSplitter The string to be expected as template field splitter. Default is `|`.\n * @param {string} opts.joinText The string to be used when the extracted value for a single cell is an array, \n * and it needs to be joined. Default is `,`.\n * @param {string|boolean} opts.mergeCells Whether to merge the higher dimension cells in the output. Default is true.\n * @param {string|boolean} opts.duplicateCells Whether to duplicate the content of higher dimension cells, when not merged. Default is false.\n * @param {boolean} opts.followFormulae If a template is located as a result of a formula, whether to still process it.\n * Default is false.\n * @param {boolean} opts.copyStyle Copy the style of the template cell when populating. Even when `false`, the template\n * styling _is_ applied. Default is true.\n * @param {object.} opts.callbacksMap A map of handlers to be used for data and value extraction.\n * There is one default - the empty one, for object key extraction.\n */\n constructor(accessor, opts) {\n this._opts = _.defaultsDeep({}, opts, defaultOpts);\n this._rowSizes = {};\n this._colSizes = {};\n this._access = accessor;\n }\n\n /**\n * Setter/getter for XlsxDataFill's options as set during construction.\n * @param {{}|null} newOpts If set - the new options to be used. \n * @see {@constructor}.\n * @returns {XlsxDataFill|{}} The required options (in getter mode) or XlsxDataFill (in setter mode) for chaining.\n */\n options(newOpts) {\n if (newOpts !== null) {\n _.merge(this._opts, newOpts);\n return this;\n } else\n return this._opts;\n }\n\n /**\n * The main entry point for whole data population mechanism.\n * @param {{}} data The data to be applied.\n * @returns {XlsxDataFill} For invocation chaining.\n */\n fillData(data) {\n const dataFills = {};\n\t\n // Build the dependency connections between templates.\n this.collectTemplates(template => {\n const aFill = { \n template: template, \n dependents: [],\n formulas: [],\n processed: false\n };\n\n if (template.reference) {\n const refFill = dataFills[template.reference];\n \n if (!refFill) \n throw new Error(`Unable to find a reference '${template.reference}'!`);\n \n if (template.formula) \n refFill.formulas.push(aFill);\n else\n refFill.dependents.push(aFill);\n \n aFill.offset = this._access.cellDistance(refFill.template.cell, template.cell);\n }\n dataFills[template.id] = aFill;\n });\n \n // Apply each fill onto the sheet.\n _.each(dataFills, fill => {\n if (fill.processed)\n return;\n else if (fill.template.formula)\n throw new Error(`Non-referencing formula found '${fill.extractor}'. Use a non-templated one!`);\n else\n this.applyFill(fill, data, fill.template.cell);\n });\n\n return this;\n }\n\n /**\n * Retrieves the provided handler from the map.\n * @param {string} handlerName The name of the handler.\n * @returns {function} The handler function itself.\n * @ignore\n */\n getHandler(handlerName) {\n const handlerFn = this._opts.callbacksMap[handlerName];\n\n if (!handlerFn)\n throw new Error(`Handler '${handlerName}' cannot be found!`);\n else if (typeof handlerFn !== 'function')\n throw new Error(`Handler '${handlerName}' is not a function!`);\n else \n return handlerFn;\n }\n\n /**\n * Parses the provided extractor (ot iterator) string to find a callback id inside, if present.\n * @param {string} extractor The iterator/extractor string to be investigated.\n * @returns {object.} A { `path`, `handler` } object representing the JSON path\n * ready for use and the provided `handler` _function_ - ready for invoking, if such is provided.\n * If not - the `path` property contains the provided `extractor`, and the `handler` is `null`.\n * @ignore\n */\n parseExtractor(extractor) {\n // A specific extractor can be specified after semilon - find and remember it.\n const extractParts = extractor.split(\":\"),\n handlerName = _.trim(extractParts[1]);\n\n return extractParts.length == 1\n ? { path: extractor, handler: null }\n : {\n path: _.trim(extractParts[0]),\n handler: this.getHandler(handlerName)\n };\n }\n\n /**\n * Applies the style part of the template onto a given cell.\n * @param {Cell} cell The destination cell to apply styling to.\n * @param {{}} data The data chunk for that cell.\n * @param {{}} template The template to be used for that cell.\n * @returns {DataFiller} For invocation chaining.\n * @ignore\n */\n applyDataStyle(cell, data, template) {\n const styles = template.styles;\n\n if (this._opts.copyStyle)\n this._access.copyStyle(cell, template.cell);\n \n if (styles && data) {\n _.each(styles, pair => {\n if (_.startsWith(pair.name, \":\")) {\n this.getHandler(pair.name.substr(1)).call(this._opts, data, cell);\n } else if (!_.startsWith(pair.name, \"!\")) {\n const val = this.extractValues(data, pair.extractor, cell);\n if (val)\n this._access.setCellStyle(cell, pair.name, JSON.parse(val));\n }\n });\n }\n\n return this;\n }\n\n /**\n * Extract the options-specific parameters from the styles field and merge them with the global ones.\n * @param {{}} template The template to extract options properties from.\n * @returns {{}} The full options, \n * @ignore\n */\n getTemplateOpts(template) {\n if (!template.styles)\n return this._opts;\n \n const opts = _.clone(this._opts);\n _.each(template.styles, pair => {\n if (_.startsWith(pair.name, \"!\"))\n opts[pair.name.substr(1)] = JSON.parse(pair.extractor);\n });\n\n return opts;\n }\n\n /**\n * Parses the contents of the cell into a valid template info.\n * @param {Cell} cell The cell containing the template to be parsed.\n * @returns {{}} The parsed template.\n * @description This method builds template info, taking into account the supplied options.\n * @ignore\n */\n parseTemplate(cell) {\n const value = this._access.cellValue(cell);\n if (value == null || typeof value !== 'string')\n return null;\n \n const reMatch = value.match(this._opts.templateRegExp);\n if (!reMatch || !this._opts.followFormulae && this._access.cellType(cell) === 'formula') \n return null;\n \n const parts = reMatch[1].split(this._opts.fieldSplitter).map(_.trim),\n styles = !parts[4] ? null : parts[4].split(\",\"),\n extractor = parts[2] || \"\",\n cellRef = this._access.buildRef(cell, parts[0]);\n \n if (parts.length < 2) \n throw new Error(`Not enough components of the template '${reMatch[0]}'`);\n if (!!parts[0] && !cellRef)\n throw new Error(`Invalid reference passed: '${parts[0]}'`);\n\n return {\n id: this._access.cellRef(cell),\n reference: cellRef,\n iterators: parts[1].split(/x|\\*/).map(_.trim),\n extractor: extractor,\n formula: extractor.startsWith(\"=\"),\n cell: cell,\n cellSize: this._access.cellSize(cell),\n padding: (parts[3] || \"\").split(/:|,|x|\\*/).map(v => parseInt(v) || 0),\n styles: !styles ? null : _.map(styles, s => {\n const pair = _.trim(s).split(\"=\");\n return { name: _.trim(pair[0]), extractor: _.trim(pair[1]) };\n })\n };\n }\n\n sortTemplates(list) {\n const sorted = [],\n related = {},\n map = {},\n freeList = [];\n\n // First, make the dependency map and add the list of non-referencing templates\n for (let i = 0; i < list.length; ++i) {\n const t = list[i];\n map[t.id] = i;\n\n if (!t.reference)\n freeList.push(t.id);\n else \n (related[t.reference] = related[t.reference] || []).push(t.id);\n }\n\n // Now, make the actual sorting.\n while (freeList.length > 0) {\n const id = freeList.shift(),\n t = list[map[id]];\n\n sorted.push(t);\n \n // We use the fact that there is a single predecessor in our setup.\n if (related[t.id])\n freeList.push(...related[t.id]);\n }\n\n if (sorted.length < list.length)\n throw new Error(`A reference cycle found, involving \"${_.map(_.xor(list, sorted), 'id').join(',')}\"!`);\n\n return sorted;\n }\n \n /**\n * Searches the whole workbook for template pattern and constructs the templates for processing.\n * @param {Function} cb The callback to be invoked on each templated, after they are sorted.\n * @returns {undefined}\n * @description The templates collected are sorted, based on the intra-template reference - if one template\n * is referring another one, it'll appear _later_ in the returned array, than the referred template.\n * This is the order the callback is being invoked on.\n * @ignore\n */\n collectTemplates(cb) {\n const allTemplates = [];\n \n this._access.forAllCells(cell => {\n const template = this.parseTemplate(cell);\n if (template)\n allTemplates.push(template);\n });\n \n return this.sortTemplates(allTemplates).forEach(cb);\n }\n\n /**\n * Extracts the value(s) from the provided data `root` to be set in the provided `cell`.\n * @param {{}} root The data root to be extracted values from.\n * @param {string} extractor The extraction string provided by the template. Usually a JSON path within the data `root`.\n * @param {Cell} cell A reference cell, if such exists.\n * @returns {string|number|Date|Array|Array.>} The value to be used.\n * @description This method is used even when a whole - possibly rectangular - range is about to be set, so it can\n * return an array of arrays.\n * @ignore\n */\n extractValues(root, extractor, cell) {\n const { path, handler } = this.parseExtractor(extractor);\n\n if (!Array.isArray(root))\n root = _.get(root, path, root);\n else if (root.sizes !== undefined)\n root = !extractor ? root : _.map(root, entry => this.extractValues(entry, extractor, cell));\n else if (!handler)\n return root.join(this._opts.joinText || \",\");\n\n return !handler ? root : handler.call(this._opts, root, cell);\n }\n\n /**\n * Extracts an array (possibly of arrays) with data for the given fill, based on the given\n * root object.\n * @param {{}} root The main reference object to apply iterators to.\n * @param {Array} iterators List of iterators - string JSON paths inside the root object.\n * @param {Number} idx The index in the iterators array to work on.\n * @returns {Array|Array.} An array (possibly of arrays) with extracted data.\n * @ignore\n */\n extractData(root, iterators, idx) {\n let iter = iterators[idx],\n sizes = [],\n transposed = false,\n data = null;\n\n if (iter == '1') {\n transposed = true;\n iter = iterators[++idx];\n }\n\n if (!iter) return root;\n\n // A specific extractor can be specified after semilon - find and remember it.\n const parsedIter = this.parseExtractor(iter);\n\n data = _.get(root, parsedIter.path, root);\n \n if (typeof parsedIter.handler === 'function')\n data = parsedIter.handler.call(this._opts, data);\n\n if (!Array.isArray(data) && typeof data === 'object')\n return data;\n else if (idx < iterators.length - 1) {\n data = _.map(data, inRoot => this.extractData(inRoot, iterators, idx + 1));\n sizes = data[0].sizes || [];\n }\n \n // data = _.values(data);\n\n // Some data sanity checks.\n if (!data)\n throw new Error(`The iterator '${iter}' extracted no data!`);\n else if (typeof data !== 'object')\n throw new Error(`The data extracted from iterator '${iter}' is neither an array, nor object!`);\n\n sizes.unshift(transposed ? -data.length : data.length);\n data.sizes = sizes;\n return data;\n }\n\n /**\n * Put the data values into the proper cells, with correct extracted values.\n * @param {{}} cell The starting cell for the data to be put.\n * @param {Array} data The actual data to be put. The values will be _extracted_ from here first.\n * @param {{}} template The template that is being implemented with that data fill.\n * @returns {Array} Matrix size that this data has occupied on the sheet [rows, cols].\n * @ignore\n */\n putValues(cell, data, template) {\n if (!cell) throw new Error(\"Crash! Null reference cell in 'putValues()'!\");\n\n let entrySize = data.sizes,\n value = this.extractValues(data, template.extractor, cell);\n\n // if we've come up with a raw data\n if (!Array.isArray(value) || !entrySize || !entrySize.length) {\n this._access.setCellValue(cell, value);\n this.applyDataStyle(cell, data, template);\n entrySize = template.cellSize;\n } else if (entrySize.length <= 2) {\n // Normalize the size and data.\n if (entrySize[0] < 0) {\n entrySize = [1, -entrySize[0]];\n value = [value];\n data = [data];\n } else if (entrySize.length == 1) {\n entrySize = entrySize.concat([1]);\n value = _.chunk(value, 1);\n data = _.chunk(data, 1);\n }\n\n this._access.getCellRange(cell, entrySize[0] - 1, entrySize[1] - 1).forEach((cell, ri, ci) => {\n this._access.setCellValue(cell, value[ri][ci]);\n this.applyDataStyle(cell, data[ri][ci], template);\n });\n } else\n throw new Error(`Values extracted with '${template.extractor}' are more than 2 dimension!'`);\n\n return entrySize;\n }\n\n /**\n * Apply the given filter onto the sheet - extracting the proper data, following dependent fills, etc.\n * @param {{}} aFill The fill to be applied, as constructed in the {@link fillData} method.\n * @param {{}} root The data root to be used for data extraction.\n * @param {Cell} mainCell The starting cell for data placement procedure.\n * @returns {Array} The size of the data put in [row, col] format.\n * @ignore\n */\n applyFill(aFill, root, mainCell) {\n const template = aFill.template,\n theData = this.extractData(root, template.iterators, 0);\n\n let entrySize = [1, 1];\n\n if (!aFill.dependents || !aFill.dependents.length)\n entrySize = this.putValues(mainCell, theData, template);\n else {\n let nextCell = mainCell;\n const sizeMaxxer = (val, idx) => entrySize[idx] = Math.max(entrySize[idx], val);\n\n for (let d = 0; d < theData.length; ++d) {\n const inRoot = theData[d];\n\n for (let f = 0; f < aFill.dependents.length; ++f) {\n const inFill = aFill.dependents[f],\n inCell = this._access.offsetCell(nextCell, inFill.offset[0], inFill.offset[1]);\n \n _.forEach(this.applyFill(inFill, inRoot, inCell), sizeMaxxer);\n }\n\n // Now we have the inner data put and the size calculated.\n _.forEach(this.putValues(nextCell, inRoot, template), sizeMaxxer);\n\n let rowOffset = entrySize[0],\n colOffset = entrySize[1],\n rowPadding = template.padding[0] || 0,\n colPadding = template.padding[1] || 0;\n\n // Make sure we grow only on one dimension.\n if (theData.sizes[0] < 0) {\n if (template.padding.length < 2)\n colPadding = rowPadding;\n rowOffset = rowPadding = 0;\n entrySize[1] = 1;\n } else if (theData.sizes.length < 2) {\n colOffset = colPadding = 0;\n entrySize[0] = 1;\n }\n\n if (rowOffset > 1 || colOffset > 1) {\n const rng = this._access.getCellRange(nextCell, Math.max(rowOffset - 1, 0), Math.max(colOffset - 1, 0)),\n _opts = this.getTemplateOpts(template);\n\n if (_opts.mergeCells === true || _opts.mergeCell === 'both'\n || rowOffset > 1 && _opts.mergeCells === 'vertical' \n || colOffset > 1 && _opts.mergeCells === 'horizontal')\n this._access.rangeMerged(rng, true);\n else if (_opts.duplicateCells === true || _opts.duplicateCells === 'both'\n || rowOffset > 1 && _opts.duplicateCells === 'vertical' \n || colOffset > 1 && _opts.duplicateCells === 'horizontal')\n this._access.duplicateCell(nextCell, rng);\n\n rng.forEach(cell => this.applyDataStyle(cell, inRoot, template));\n }\n\n // Finally, calculate the next cell.\n nextCell = this._access.offsetCell(nextCell, rowOffset + rowPadding, colOffset + colPadding);\t\n }\n\n // Now recalc combined entry size.\n _.forEach(this._access.cellDistance(mainCell, nextCell), sizeMaxxer);\n }\n\n _.forEach(aFill.formulas, f => this.applyFormula(f, entrySize, mainCell));\n\n aFill.processed = true;\n return entrySize;\n }\n\n /**\n * Process a formula be shifting all the fixed offset.\n * @param {String} formula The formula to be shifted.\n * @param {Array} offset The offset of the referenced template to the formula one.\n * @param {Array} size The size of the ranges as they should be.\n * @returns {String} The processed text.\n * @ignore\n */\n shiftFormula(formula, offset, size) {\n let newFormula = '';\n\n for (;;) {\n const match = formula.match(refRegExp);\n if (!match) break;\n\n let from = this._access.getCell(match[3], match[2]),\n newRef = null;\n\n if (offset[0] > 0 || offset[1] > 0)\n from = this._access.offsetCell(from, offset[0], offset[1]);\n\n newRef = !match[5]\n ? this._access.cellRef(from, !!match[2])\n : this._access.rangeRef(this._access.getCellRange(from, size[0], size[1]), !!match[2]);\n\n newFormula += formula.substr(0, match.index) + newRef;\n formula = formula.substr(match.index + match[0].length);\n }\n\n newFormula += formula;\n return newFormula;\n }\n\n /**\n * Apply the given formula in the sheet, i.e. changing it to match the \n * sizes of the references templates.\n * @param {{}} aFill The fill to be applied, as constructed in the {@link fillData} method.\n * @param {Array} entrySize The fill-to-size map, as constructed so far\n * @param {Cell} cell The cell to put/start this formula into\n * @returns {undefined}\n * @ignore\n */\n applyFormula(aFill, entrySize, cell) {\n cell = this._access.offsetCell(cell, aFill.offset[0], aFill.offset[1]);\n\n const template = aFill.template,\n iter = _.trim(template.iterators[0]),\n offset = this._access.cellDistance(template.cell, cell);\n \n let formula = template.extractor, \n rng;\n \n aFill.processed = true;\n this._access.setCellValue(cell, null);\n\n if (entrySize[0] < 2 && entrySize[1] < 2 || iter === 'both') {\n formula = this.shiftFormula(formula, offset, [0, 0]);\n rng = this._access.getCellRange(cell, entrySize[0] - 1, entrySize[1] - 1);\n } else if (iter === 'cols') {\n formula = this.shiftFormula(formula, offset, [entrySize[0] - 1, 0]);\n rng = this._access.getCellRange(cell, 0, entrySize[1] - 1);\n } else if (iter === 'rows') {\n formula = this.shiftFormula(formula, offset, [0, entrySize[1] - 1]);\n rng = this._access.getCellRange(cell, entrySize[0] - 1, 0);\n } else { // i.e. 'none'\n this._access.setCellFormula(cell, this.shiftFormula(formula, offset, [entrySize[0] - 1, entrySize[1] - 1]));\n return;\n }\n\n this._access.setRangeFormula(rng, formula);\n }\n}\n\n/**\n * The built-in accessor based on xlsx-populate npm module\n * @type {XlsxPopulateAccess}\n */\nXlsxDataFill.XlsxPopulateAccess = require('./XlsxPopulateAccess');\nXlsxDataFill.version = \"{{VERSION}}\";\n\nmodule.exports = XlsxDataFill;\n","\"use strict\";\n\nconst _ = require('lodash');\n\n// const allStyles = [\n// \"bold\", \n// \"italic\", \n// \"underline\", \n// \"strikethrough\", \n// \"subscript\", \n// \"superscript\", \n// \"fontSize\", \n// \"fontFamily\", \n// \"fontGenericFamily\", \n// \"fontScheme\", \n// \"fontColor\", \n// \"horizontalAlignment\", \n// \"justifyLastLine\", \n// \"indent\", \n// \"verticalAlignment\", \n// \"wrapText\", \n// \"shrinkToFit\", \n// \"textDirection\", \n// \"textRotation\", \n// \"angleTextCounterclockwise\", \n// \"angleTextClockwise\", \n// \"rotateTextUp\", \n// \"rotateTextDown\", \n// \"verticalText\", \n// \"fill\", \n// \"border\", \n// \"borderColor\", \n// \"borderStyle\", \n// \"leftBorder\", \"rightBorder\", \"topBorder\", \"bottomBorder\", \"diagonalBorder\", \n// \"leftBorderColor\", \"rightBorderColor\", \"topBorderColor\", \"bottomBorderColor\", \"diagonalBorderColor\", \n// \"leftBorderStyle\", \"rightBorderStyle\", \"topBorderStyle\", \"bottomBorderStyle\", \"diagonalBorderStyle\", \n// \"diagonalBorderDirection\", \n// \"numberFormat\"\n// ];\n\nlet _RichText = null;\n\n/**\n * `xslx-populate` library based accessor to a given Excel workbook. All these methods are internally used by {@link XlsxDataFill}, \n * but can be used as a reference for implementing custom spreadsheet accessors.\n */\nclass XlsxPopulateAccess {\n /**\n * Constructs a new instance of XlsxSmartTemplate with given options.\n * @param {Workbook} workbook - The workbook to be accessed.\n * @param {XlsxPopulate} XlsxPopulate - The actual xlsx-populate library object.\n * @description The `XlsxPopulate` object need to be passed in order to extract\n * certain information from it, _without_ referring the whole library, thus\n * avoiding making the `xlsx-datafill` package a dependency.\n */\n constructor(workbook, XlsxPopulate) {\n this._workbook = workbook;\n this._rowSizes = {};\n this._colSizes = {};\n \n _RichText = XlsxPopulate.RichText;\n }\n\n /**\n * Returns the configured workbook for direct XlsxPopulate manipulation.\n * @returns {Workbook} The workbook involved.\n */\n workbook() {\n return this._workbook; \n }\n\n /**\n * Gets the textual representation of the cell value.\n * @param {Cell} cell - The cell to retrieve the value from.\n * @returns {string} The textual representation of cell's contents.\n */\n cellValue(cell) {\n const theValue = cell.value();\n return theValue instanceof _RichText ? theValue.text() : theValue;\n }\n\n /**\n * Sets the cell value.\n * @param {Cell} cell - The cell to retrieve the value from.\n * @param {*} value - The requested value for setting.\n * @returns {XlsxPopulateAccess} Either the requested value or chainable this.\n */\n setCellValue(cell, value) {\n cell.value(value);\n return this;\n }\n\n /**\n * Gets the textual representation of the cell value.\n * @param {Cell} cell - The cell to retrieve the value from.\n * @returns {string} The type of the cell - 'formula', 'richtext', \n * 'text', 'number', 'date', 'hyperlink', or 'unknown';\n */\n cellType(cell) {\n if (cell.formula())\n return 'formula';\n else if (cell.hyperlink())\n return 'hyperlink';\n \n const theValue = cell.value();\n if (theValue instanceof _RichText)\n return 'richtext';\n else if (theValue instanceof Date)\n return 'date';\n else \n return typeof theValue;\n }\n\n /**\n * Sets the formula in the cell\n * @param {Cell} cell - The cell to retrieve the value from.\n * @param {string} formula - the text of the formula to be set.\n * @returns {XlsxPopulateAccess} For chaining.\n */\n setCellFormula(cell, formula) {\n cell.formula(_.trimStart(formula, ' ='));\n return this;\n }\n\n /**\n * Measures the distance, as a vector between two given cells.\n * @param {Cell} from The first cell.\n * @param {Cell} to The second cell.\n * @returns {Array.} An array with two values [, ], representing the distance between the two cells.\n */\n cellDistance(from, to) {\n return [\n to.rowNumber() - from.rowNumber(),\n to.columnNumber() - from.columnNumber()\n ];\n }\n\n /**\n * Determines the size of cell, taking into account if it is part of a merged range.\n * @param {Cell} cell The cell to be investigated.\n * @returns {Array.} An array with two values [, ], representing the occupied size.\n */\n cellSize(cell) {\n const cellAddr = cell.address();\n let theSize = [1, 1];\n \n _.forEach(cell.sheet()._mergeCells, range => {\n const rangeAddr = range.attributes.ref.split(\":\");\n if (rangeAddr[0] == cellAddr) {\n theSize = this.cellDistance(cell, cell.sheet().cell(rangeAddr[1]));\n ++theSize[0];\n ++theSize[1];\n return false;\n }\n });\n \n return theSize;\n }\n\n /**\n * Sets a named style of a given cell.\n * @param {Cell} cell The cell to be operated.\n * @param {string} name The name of the style property to be set.\n * @param {string|object} value The value for this property to be set.\n * @returns {XlsxPopulateAccess} For invocation chaining.\n */\n setCellStyle(cell, name, value) {\n cell.style(name, value);\n return this;\n }\n\n /**\n * Creates a reference Id for a given cell, based on its sheet and address.\n * @param {Cell} cell The cell to create a reference Id to.\n * @param {boolean} withSheet Whether to include the sheet name in the reference. Defaults to true.\n * @returns {string} The id to be used as a reference for this cell.\n */\n cellRef(cell, withSheet) {\n if (withSheet == null)\n withSheet = true;\n return cell.address({ includeSheetName: withSheet });\n }\n\n /**\n * Build a reference string for a cell identified by @param adr, from the @param cell.\n * @param {Cell} cell A cell that is a base of the reference.\n * @param {string} adr The address of the target cell, as mentioned in @param cell.\n * @param {boolean} withSheet Whether to include the sheet name in the reference. Defaults to true.\n * @returns {string} A reference string identifying the target cell uniquely.\n */\n buildRef(cell, adr, withSheet) {\n if (withSheet == null)\n withSheet = true;\n return adr ? cell.sheet().cell(adr).address({ includeSheetName: withSheet }) : null;\n }\n\n /**\n * Retrieves a given cell from a given sheet (or an active one).\n * @param {string|object|array} address The cell adress to be used\n * @param {string|idx} sheetId The id/name of the sheet to retrieve the cell from. Defaults to an active one.\n * @returns {Cell} A reference to the required cell.\n */\n getCell(address, sheetId) {\n const theSheet = sheetId == null ? this._workbook.activeSheet() : this._workbook.sheet(sheetId);\n return theSheet.cell(address);\n }\n\n /**\n * Duplicates a cell across a given range.\n * @param {Cell} cell Cell, which needs duplicating.\n * @param {Range} range The range, as returned from {@link getCellRange}\n * @returns {XlsxPopulateAccess} For chain invokes.\n */\n duplicateCell(cell, range) {\n range.value(cell.value());\n return this;\n }\n\n /**\n * Constructs and returns the range starting from the given cell and spawning given rows and cells.\n * @param {Cell} cell The starting cell of the range.\n * @param {Number} rowOffset Number of rows away from the starting cell. 0 means same row.\n * @param {Number} colOffset Number of columns away from the starting cell. 0 means same column.\n * @returns {Range} The constructed range.\n */\n getCellRange(cell, rowOffset, colOffset) {\n return cell.rangeTo(cell.relativeCell(rowOffset, colOffset));\n }\n\n /**\n * Gets the cell at a certain offset from a given one.\n * @param {Cell} cell The reference cell to make the offset from.\n * @param {int} rows Number of rows to offset.\n * @param {int} cols Number of columns to offset.\n * @returns {Cell} The resulting cell.\n */\n offsetCell(cell, rows, cols) {\n return cell.relativeCell(rows, cols);\n }\n\n /**\n * Merge or split range of cells.\n * @param {Range} range The range, as returned from {@link getCellRange}\n * @param {boolean} status The merged status to be set.\n * @returns {XlsxPopulateAccess} For chain invokes.\n */\n rangeMerged(range, status) {\n if (status === undefined)\n return range.merged();\n else {\n range.merged(status);\n return this;\n }\n }\n\n /**\n * Sets a formula for the whole range. If it contains only one - it is set directly.\n * @param {Range} range The range, as returned from {@link getCellRange}\n * @param {String} formula The formula to be set.\n * @returns {XlsxPopulateAccess} For chain invokes.\n */\n setRangeFormula(range, formula) {\n range.formula(_.trimStart(formula, ' ='));\n return this;\n }\n\n /**\n * Return the string representation of a given range.\n * @param {Range} range The range which address we're interested in.\n * @param {boolean} withSheet Whether to include sheet name in the address.\n * @return {String} The string, representing the given range.\n */\n rangeRef(range, withSheet) {\n if (withSheet == null)\n withSheet = true;\n return range.address({ includeSheetName: withSheet });\n }\n\n /**\n * Iterate over all used cells of the given workbook.\n * @param {function} cb The callback to be invoked with `cell` argument for each used cell.\n * @returns {XlsxPopulateAccess} For chain invokes.\n */\n forAllCells(cb) {\n this._workbook.sheets().forEach(sheet => {\n const theRange = sheet.usedRange();\n if (theRange) \n theRange.forEach(cb);\n });\n return this;\n }\n\n /**\n * Copies the styles from `src` cell to the `dest`-ination one.\n * @param {Cell} dest Destination cell.\n * @param {Cell} src Source cell.\n * @returns {XlsxPopulateAccess} For invocation chaining.\n */\n copyStyle(dest, src) {\n if (!src || !dest) throw new Error(\"Crash! Null 'src' or 'dest' for copyStyle()!\");\n if (src == dest) return this;\n\n if (src._style !== undefined)\n dest.style(src._style);\n else if (src._styleId > 0)\n dest._styleId = src._styleId;\n\n const destSheetId = dest.sheet().name(),\n rowId = `'${destSheetId}':${dest.rowNumber()}`,\n colId = `'${destSheetId}':${dest.columnNumber()}`;\n\n if (this._rowSizes[rowId] === undefined)\n dest.row().height(this._rowSizes[rowId] = src.row().height());\n \n if (this._colSizes[colId] === undefined)\n dest.column().width(this._colSizes[colId] = src.column().width());\n\n return this;\n }\n}\n\nmodule.exports = XlsxPopulateAccess;\n"]} \ No newline at end of file +{"version":3,"sources":["node_modules/browser-pack/_prelude.js","src/XlsxDataFill.js","src/XlsxPopulateAccess.js"],"names":["f","exports","module","define","amd","window","global","self","this","XlsxDataFill","r","e","n","t","o","i","c","require","u","a","Error","code","p","call","length","1","_2","defaultOpts","templateRegExp","fieldSplitter","joinText","mergeCells","duplicateCells","followFormulae","copyStyle","callbacksMap","","data","keys","$","values","refRegExp","accessor","opts","_classCallCheck","_opts","defaultsDeep","_rowSizes","_colSizes","_access","newOpts","merge","_this","dataFills","collectTemplates","template","aFill","dependents","formulas","processed","reference","refFill","concat","formula","push","offset","cellDistance","cell","id","each","fill","extractor","applyFill","handlerName","handlerFn","extractParts","split","trim","path","handler","getHandler","_this2","styles","pair","startsWith","name","substr","val","extractValues","setCellStyle","JSON","parse","clone","value","cellValue","reMatch","match","cellType","parts","map","cellRef","buildRef","iterators","cellSize","padding","v","parseInt","s","list","sorted","related","freeList","_t","shift","apply","_toConsumableArray","xor","join","cb","_this3","allTemplates","forAllCells","parseTemplate","sortTemplates","forEach","root","_this4","_this$parseExtractor","parseExtractor","Array","isArray","undefined","sizes","entry","get","idx","_this5","iter","transposed","parsedIter","_typeof","inRoot","extractData","unshift","_this6","entrySize","chunk","getCellRange","ri","ci","setCellValue","applyDataStyle","mainCell","_this7","theData","nextCell","sizeMaxxer","Math","max","_loop","d","inFill","inCell","offsetCell","putValues","rowOffset","colOffset","rowPadding","colPadding","rng","getTemplateOpts","mergeCell","rangeMerged","duplicateCell","applyFormula","size","newFormula","newRef","from","getCell","rangeRef","index","shiftFormula","setCellFormula","setRangeFormula","XlsxPopulateAccess","version","_","_RichText","workbook","XlsxPopulate","_workbook","RichText","theValue","text","hyperlink","Date","trimStart","to","rowNumber","columnNumber","cellAddr","address","theSize","sheet","_mergeCells","range","rangeAddr","attributes","ref","style","withSheet","includeSheetName","adr","sheetId","activeSheet","rangeTo","relativeCell","rows","cols","status","merged","sheets","theRange","usedRange","dest","src","_style","_styleId","destSheetId","rowId","colId","row","height","column","width"],"mappings":"CAAA,SAAAA,GAAA,GAAA,iBAAAC,SAAA,oBAAAC,OAAAA,OAAAD,QAAAD,SAAA,GAAA,mBAAAG,QAAAA,OAAAC,IAAAD,OAAA,GAAAH,OAAA,EAAA,oBAAAK,OAAAA,OAAA,oBAAAC,OAAAA,OAAA,oBAAAC,KAAAA,KAAAC,MAAAC,aAAAT,KAAA,EAAA,WAAA,OAAA,SAAAU,EAAAC,EAAAC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,aACjCgC,EAAK,IAAAzK,OAAOuK,EAAP,MAAAvK,OAAuBmK,EAAKzB,gBAQrC,YAN8BrE,IAA1B3H,KAAKuC,UAAUuL,IACfL,EAAKO,MAAMC,OAAOjO,KAAKuC,UAAUuL,GAASJ,EAAIM,MAAMC,eAE1BtG,IAA1B3H,KAAKwC,UAAUuL,IACfN,EAAKS,SAASC,MAAMnO,KAAKwC,UAAUuL,GAASL,EAAIQ,SAASC,SAEtDnO,0CAIfN,EAAOD,QAAUwL,iIFjUjB","file":"xlsx-datafill.min.js","sourcesContent":["(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i _.keys(data),\n $: data => _.values(data)\n }\n};\n\nconst refRegExp = /('?([^!]*)?'?!)?([A-Z]+\\d+)(:([A-Z]+\\d+))?/;\n\n/**\n * Data fill engine, taking an instance of Excel sheet accessor and a JSON object as data, and filling the values from the latter into the former.\n */\nclass XlsxDataFill {\n /**\n * Constructs a new instance of XlsxDataFill with given options.\n * @param {object} accessor An instance of XLSX spreadsheet accessing class.\n * @param {{}} opts Options to be used during processing.\n * @param {RegExp} opts.templateRegExp The regular expression to be used for template recognizing. Default is `/\\{\\{([^}]*)\\}\\}/`, i.e. Mustache.\n * @param {string|RegExo} opts.fieldSplitter The string or regular expression to be used as template fields splitter. Default is `|`.\n * @param {string} opts.joinText The string to be used when the extracted value for a single cell is an array, and it needs to be joined. Default is `,`.\n * @param {string|boolean} opts.mergeCells Whether to merge the higher dimension cells in the output. Default is true, but valid values are also `\"both\"`, `\"vertical\"` and `\"horizontal\"`.\n * @param {string|boolean} opts.duplicateCells Whether to duplicate the content of higher dimension cells, when not merged. Default is false. Same valud values as `mergeCells`.\n * @param {boolean} opts.followFormulae If a template is located as a result of a formula, whether to still process it. Default is false.\n * @param {boolean} opts.copyStyle Copy the style of the template cell when populating. Even when `false`, the template styling _is_ applied. Default is true.\n * @param {object.} opts.callbacksMap A map of handlers to be used for data and value extraction.\n */\n constructor(accessor, opts) {\n this._opts = _.defaultsDeep({}, opts, defaultOpts);\n this._rowSizes = {};\n this._colSizes = {};\n this._access = accessor;\n }\n\n /**\n * Setter/getter for XlsxDataFill's options as set during construction.\n * @param {{}|null} newOpts If set - the new options to be used. Check [up here]{@link #new-xlsxdatafillaccessor-opts}.\n * @returns {XlsxDataFill|{}} The required options (in getter mode) or XlsxDataFill (in setter mode) for chaining.\n */\n options(newOpts) {\n if (newOpts !== null) {\n _.merge(this._opts, newOpts);\n return this;\n } else\n return this._opts;\n }\n\n /**\n * The main entry point for whole data population mechanism.\n * @param {{}} data The data to be applied.\n * @returns {XlsxDataFill} For invocation chaining.\n */\n fillData(data) {\n const dataFills = {};\n\t\n // Build the dependency connections between templates.\n this.collectTemplates(template => {\n const aFill = { \n template: template, \n dependents: [],\n formulas: [],\n processed: false\n };\n\n if (template.reference) {\n const refFill = dataFills[template.reference];\n \n if (!refFill) \n throw new Error(`Unable to find a reference '${template.reference}'!`);\n \n if (template.formula) \n refFill.formulas.push(aFill);\n else\n refFill.dependents.push(aFill);\n \n aFill.offset = this._access.cellDistance(refFill.template.cell, template.cell);\n }\n dataFills[template.id] = aFill;\n });\n \n // Apply each fill onto the sheet.\n _.each(dataFills, fill => {\n if (fill.processed)\n return;\n else if (fill.template.formula)\n throw new Error(`Non-referencing formula found '${fill.extractor}'. Use a non-templated one!`);\n else\n this.applyFill(fill, data, fill.template.cell);\n });\n\n return this;\n }\n\n /**\n * Retrieves the provided handler from the map.\n * @param {string} handlerName The name of the handler.\n * @returns {function} The handler function itself.\n * @ignore\n */\n getHandler(handlerName) {\n const handlerFn = this._opts.callbacksMap[handlerName];\n\n if (!handlerFn)\n throw new Error(`Handler '${handlerName}' cannot be found!`);\n else if (typeof handlerFn !== 'function')\n throw new Error(`Handler '${handlerName}' is not a function!`);\n else \n return handlerFn;\n }\n\n /**\n * Parses the provided extractor (ot iterator) string to find a callback id inside, if present.\n * @param {string} extractor The iterator/extractor string to be investigated.\n * @returns {object.} A { `path`, `handler` } object representing the JSON path\n * ready for use and the provided `handler` _function_ - ready for invoking, if such is provided.\n * If not - the `path` property contains the provided `extractor`, and the `handler` is `null`.\n * @ignore\n */\n parseExtractor(extractor) {\n // A specific extractor can be specified after semilon - find and remember it.\n const extractParts = extractor.split(\":\"),\n handlerName = _.trim(extractParts[1]);\n\n return extractParts.length == 1\n ? { path: extractor, handler: null }\n : {\n path: _.trim(extractParts[0]),\n handler: this.getHandler(handlerName)\n };\n }\n\n /**\n * Applies the style part of the template onto a given cell.\n * @param {Cell} cell The destination cell to apply styling to.\n * @param {{}} data The data chunk for that cell.\n * @param {{}} template The template to be used for that cell.\n * @returns {DataFiller} For invocation chaining.\n * @ignore\n */\n applyDataStyle(cell, data, template) {\n const styles = template.styles;\n\n if (this._opts.copyStyle)\n this._access.copyStyle(cell, template.cell);\n \n if (styles && data) {\n _.each(styles, pair => {\n if (_.startsWith(pair.name, \":\")) {\n this.getHandler(pair.name.substr(1)).call(this._opts, data, cell);\n } else if (!_.startsWith(pair.name, \"!\")) {\n const val = this.extractValues(data, pair.extractor, cell);\n if (val)\n this._access.setCellStyle(cell, pair.name, JSON.parse(val));\n }\n });\n }\n\n return this;\n }\n\n /**\n * Extract the options-specific parameters from the styles field and merge them with the global ones.\n * @param {{}} template The template to extract options properties from.\n * @returns {{}} The full options, \n * @ignore\n */\n getTemplateOpts(template) {\n if (!template.styles)\n return this._opts;\n \n const opts = _.clone(this._opts);\n _.each(template.styles, pair => {\n if (_.startsWith(pair.name, \"!\"))\n opts[pair.name.substr(1)] = JSON.parse(pair.extractor);\n });\n\n return opts;\n }\n\n /**\n * Parses the contents of the cell into a valid template info.\n * @param {Cell} cell The cell containing the template to be parsed.\n * @returns {{}} The parsed template.\n * @description This method builds template info, taking into account the supplied options.\n * @ignore\n */\n parseTemplate(cell) {\n const value = this._access.cellValue(cell);\n if (value == null || typeof value !== 'string')\n return null;\n \n const reMatch = value.match(this._opts.templateRegExp);\n if (!reMatch || !this._opts.followFormulae && this._access.cellType(cell) === 'formula') \n return null;\n \n const parts = reMatch[1].split(this._opts.fieldSplitter).map(_.trim),\n styles = !parts[4] ? null : parts[4].split(\",\"),\n extractor = parts[2] || \"\",\n cellRef = this._access.buildRef(cell, parts[0]);\n \n if (parts.length < 2) \n throw new Error(`Not enough components of the template '${reMatch[0]}'`);\n if (!!parts[0] && !cellRef)\n throw new Error(`Invalid reference passed: '${parts[0]}'`);\n\n return {\n id: this._access.cellRef(cell),\n reference: cellRef,\n iterators: parts[1].split(/x|\\*/).map(_.trim),\n extractor: extractor,\n formula: extractor.startsWith(\"=\"),\n cell: cell,\n cellSize: this._access.cellSize(cell),\n padding: (parts[3] || \"\").split(/:|,|x|\\*/).map(v => parseInt(v) || 0),\n styles: !styles ? null : _.map(styles, s => {\n const pair = _.trim(s).split(\"=\");\n return { name: _.trim(pair[0]), extractor: _.trim(pair[1]) };\n })\n };\n }\n\n sortTemplates(list) {\n const sorted = [],\n related = {},\n map = {},\n freeList = [];\n\n // First, make the dependency map and add the list of non-referencing templates\n for (let i = 0; i < list.length; ++i) {\n const t = list[i];\n map[t.id] = i;\n\n if (!t.reference)\n freeList.push(t.id);\n else \n (related[t.reference] = related[t.reference] || []).push(t.id);\n }\n\n // Now, make the actual sorting.\n while (freeList.length > 0) {\n const id = freeList.shift(),\n t = list[map[id]];\n\n sorted.push(t);\n \n // We use the fact that there is a single predecessor in our setup.\n if (related[t.id])\n freeList.push(...related[t.id]);\n }\n\n if (sorted.length < list.length)\n throw new Error(`A reference cycle found, involving \"${_.map(_.xor(list, sorted), 'id').join(',')}\"!`);\n\n return sorted;\n }\n \n /**\n * Searches the whole workbook for template pattern and constructs the templates for processing.\n * @param {Function} cb The callback to be invoked on each templated, after they are sorted.\n * @returns {undefined}\n * @description The templates collected are sorted, based on the intra-template reference - if one template\n * is referring another one, it'll appear _later_ in the returned array, than the referred template.\n * This is the order the callback is being invoked on.\n * @ignore\n */\n collectTemplates(cb) {\n const allTemplates = [];\n \n this._access.forAllCells(cell => {\n const template = this.parseTemplate(cell);\n if (template)\n allTemplates.push(template);\n });\n \n return this.sortTemplates(allTemplates).forEach(cb);\n }\n\n /**\n * Extracts the value(s) from the provided data `root` to be set in the provided `cell`.\n * @param {{}} root The data root to be extracted values from.\n * @param {string} extractor The extraction string provided by the template. Usually a JSON path within the data `root`.\n * @param {Cell} cell A reference cell, if such exists.\n * @returns {string|number|Date|Array|Array.>} The value to be used.\n * @description This method is used even when a whole - possibly rectangular - range is about to be set, so it can\n * return an array of arrays.\n * @ignore\n */\n extractValues(root, extractor, cell) {\n const { path, handler } = this.parseExtractor(extractor);\n\n if (!Array.isArray(root))\n root = _.get(root, path, root);\n else if (root.sizes !== undefined)\n root = !extractor ? root : _.map(root, entry => this.extractValues(entry, extractor, cell));\n else if (!handler)\n return root.join(this._opts.joinText || \",\");\n\n return !handler ? root : handler.call(this._opts, root, cell);\n }\n\n /**\n * Extracts an array (possibly of arrays) with data for the given fill, based on the given\n * root object.\n * @param {{}} root The main reference object to apply iterators to.\n * @param {Array} iterators List of iterators - string JSON paths inside the root object.\n * @param {Number} idx The index in the iterators array to work on.\n * @returns {Array|Array.} An array (possibly of arrays) with extracted data.\n * @ignore\n */\n extractData(root, iterators, idx) {\n let iter = iterators[idx],\n sizes = [],\n transposed = false,\n data = null;\n\n if (iter == '1') {\n transposed = true;\n iter = iterators[++idx];\n }\n\n if (!iter) return root;\n\n // A specific extractor can be specified after semilon - find and remember it.\n const parsedIter = this.parseExtractor(iter);\n\n data = _.get(root, parsedIter.path, root);\n \n if (typeof parsedIter.handler === 'function')\n data = parsedIter.handler.call(this._opts, data);\n\n if (!Array.isArray(data) && typeof data === 'object')\n return data;\n else if (idx < iterators.length - 1) {\n data = _.map(data, inRoot => this.extractData(inRoot, iterators, idx + 1));\n sizes = data[0].sizes || [];\n }\n \n // data = _.values(data);\n\n // Some data sanity checks.\n if (!data)\n throw new Error(`The iterator '${iter}' extracted no data!`);\n else if (typeof data !== 'object')\n throw new Error(`The data extracted from iterator '${iter}' is neither an array, nor object!`);\n\n sizes.unshift(transposed ? -data.length : data.length);\n data.sizes = sizes;\n return data;\n }\n\n /**\n * Put the data values into the proper cells, with correct extracted values.\n * @param {{}} cell The starting cell for the data to be put.\n * @param {Array} data The actual data to be put. The values will be _extracted_ from here first.\n * @param {{}} template The template that is being implemented with that data fill.\n * @returns {Array} Matrix size that this data has occupied on the sheet [rows, cols].\n * @ignore\n */\n putValues(cell, data, template) {\n if (!cell) throw new Error(\"Crash! Null reference cell in 'putValues()'!\");\n\n let entrySize = data.sizes,\n value = this.extractValues(data, template.extractor, cell);\n\n // if we've come up with a raw data\n if (!Array.isArray(value) || !entrySize || !entrySize.length) {\n this._access.setCellValue(cell, value);\n this.applyDataStyle(cell, data, template);\n entrySize = template.cellSize;\n } else if (entrySize.length <= 2) {\n // Normalize the size and data.\n if (entrySize[0] < 0) {\n entrySize = [1, -entrySize[0]];\n value = [value];\n data = [data];\n } else if (entrySize.length == 1) {\n entrySize = entrySize.concat([1]);\n value = _.chunk(value, 1);\n data = _.chunk(data, 1);\n }\n\n this._access.getCellRange(cell, entrySize[0] - 1, entrySize[1] - 1).forEach((cell, ri, ci) => {\n this._access.setCellValue(cell, value[ri][ci]);\n this.applyDataStyle(cell, data[ri][ci], template);\n });\n } else\n throw new Error(`Values extracted with '${template.extractor}' are more than 2 dimension!'`);\n\n return entrySize;\n }\n\n /**\n * Apply the given filter onto the sheet - extracting the proper data, following dependent fills, etc.\n * @param {{}} aFill The fill to be applied, as constructed in the {@link fillData} method.\n * @param {{}} root The data root to be used for data extraction.\n * @param {Cell} mainCell The starting cell for data placement procedure.\n * @returns {Array} The size of the data put in [row, col] format.\n * @ignore\n */\n applyFill(aFill, root, mainCell) {\n const template = aFill.template,\n theData = this.extractData(root, template.iterators, 0);\n\n let entrySize = [1, 1];\n\n if (!aFill.dependents || !aFill.dependents.length)\n entrySize = this.putValues(mainCell, theData, template);\n else {\n let nextCell = mainCell;\n const sizeMaxxer = (val, idx) => entrySize[idx] = Math.max(entrySize[idx], val);\n\n for (let d = 0; d < theData.length; ++d) {\n const inRoot = theData[d];\n\n for (let f = 0; f < aFill.dependents.length; ++f) {\n const inFill = aFill.dependents[f],\n inCell = this._access.offsetCell(nextCell, inFill.offset[0], inFill.offset[1]);\n \n _.forEach(this.applyFill(inFill, inRoot, inCell), sizeMaxxer);\n }\n\n // Now we have the inner data put and the size calculated.\n _.forEach(this.putValues(nextCell, inRoot, template), sizeMaxxer);\n\n let rowOffset = entrySize[0],\n colOffset = entrySize[1],\n rowPadding = template.padding[0] || 0,\n colPadding = template.padding[1] || 0;\n\n // Make sure we grow only on one dimension.\n if (theData.sizes[0] < 0) {\n if (template.padding.length < 2)\n colPadding = rowPadding;\n rowOffset = rowPadding = 0;\n entrySize[1] = 1;\n } else if (theData.sizes.length < 2) {\n colOffset = colPadding = 0;\n entrySize[0] = 1;\n }\n\n if (rowOffset > 1 || colOffset > 1) {\n const rng = this._access.getCellRange(nextCell, Math.max(rowOffset - 1, 0), Math.max(colOffset - 1, 0)),\n _opts = this.getTemplateOpts(template);\n\n if (_opts.mergeCells === true || _opts.mergeCell === 'both'\n || rowOffset > 1 && _opts.mergeCells === 'vertical' \n || colOffset > 1 && _opts.mergeCells === 'horizontal')\n this._access.rangeMerged(rng, true);\n else if (_opts.duplicateCells === true || _opts.duplicateCells === 'both'\n || rowOffset > 1 && _opts.duplicateCells === 'vertical' \n || colOffset > 1 && _opts.duplicateCells === 'horizontal')\n this._access.duplicateCell(nextCell, rng);\n\n rng.forEach(cell => this.applyDataStyle(cell, inRoot, template));\n }\n\n // Finally, calculate the next cell.\n nextCell = this._access.offsetCell(nextCell, rowOffset + rowPadding, colOffset + colPadding);\t\n }\n\n // Now recalc combined entry size.\n _.forEach(this._access.cellDistance(mainCell, nextCell), sizeMaxxer);\n }\n\n _.forEach(aFill.formulas, f => this.applyFormula(f, entrySize, mainCell));\n\n aFill.processed = true;\n return entrySize;\n }\n\n /**\n * Process a formula be shifting all the fixed offset.\n * @param {String} formula The formula to be shifted.\n * @param {Array} offset The offset of the referenced template to the formula one.\n * @param {Array} size The size of the ranges as they should be.\n * @returns {String} The processed text.\n * @ignore\n */\n shiftFormula(formula, offset, size) {\n let newFormula = '';\n\n for (;;) {\n const match = formula.match(refRegExp);\n if (!match) break;\n\n let from = this._access.getCell(match[3], match[2]),\n newRef = null;\n\n if (offset[0] > 0 || offset[1] > 0)\n from = this._access.offsetCell(from, offset[0], offset[1]);\n\n newRef = !match[5]\n ? this._access.cellRef(from, !!match[2])\n : this._access.rangeRef(this._access.getCellRange(from, size[0], size[1]), !!match[2]);\n\n newFormula += formula.substr(0, match.index) + newRef;\n formula = formula.substr(match.index + match[0].length);\n }\n\n newFormula += formula;\n return newFormula;\n }\n\n /**\n * Apply the given formula in the sheet, i.e. changing it to match the \n * sizes of the references templates.\n * @param {{}} aFill The fill to be applied, as constructed in the {@link fillData} method.\n * @param {Array} entrySize The fill-to-size map, as constructed so far\n * @param {Cell} cell The cell to put/start this formula into\n * @returns {undefined}\n * @ignore\n */\n applyFormula(aFill, entrySize, cell) {\n cell = this._access.offsetCell(cell, aFill.offset[0], aFill.offset[1]);\n\n const template = aFill.template,\n iter = _.trim(template.iterators[0]),\n offset = this._access.cellDistance(template.cell, cell);\n \n let formula = template.extractor, \n rng;\n \n aFill.processed = true;\n this._access.setCellValue(cell, null);\n\n if (entrySize[0] < 2 && entrySize[1] < 2 || iter === 'both') {\n formula = this.shiftFormula(formula, offset, [0, 0]);\n rng = this._access.getCellRange(cell, entrySize[0] - 1, entrySize[1] - 1);\n } else if (iter === 'cols') {\n formula = this.shiftFormula(formula, offset, [entrySize[0] - 1, 0]);\n rng = this._access.getCellRange(cell, 0, entrySize[1] - 1);\n } else if (iter === 'rows') {\n formula = this.shiftFormula(formula, offset, [0, entrySize[1] - 1]);\n rng = this._access.getCellRange(cell, entrySize[0] - 1, 0);\n } else { // i.e. 'none'\n this._access.setCellFormula(cell, this.shiftFormula(formula, offset, [entrySize[0] - 1, entrySize[1] - 1]));\n return;\n }\n\n this._access.setRangeFormula(rng, formula);\n }\n}\n\n/**\n * The built-in accessor based on xlsx-populate npm module\n * @type {XlsxPopulateAccess}\n */\nXlsxDataFill.XlsxPopulateAccess = require('./XlsxPopulateAccess');\nXlsxDataFill.version = \"{{VERSION}}\";\n\nmodule.exports = XlsxDataFill;\n","\"use strict\";\n\nconst _ = require('lodash');\n\n// const allStyles = [\n// \"bold\", \n// \"italic\", \n// \"underline\", \n// \"strikethrough\", \n// \"subscript\", \n// \"superscript\", \n// \"fontSize\", \n// \"fontFamily\", \n// \"fontGenericFamily\", \n// \"fontScheme\", \n// \"fontColor\", \n// \"horizontalAlignment\", \n// \"justifyLastLine\", \n// \"indent\", \n// \"verticalAlignment\", \n// \"wrapText\", \n// \"shrinkToFit\", \n// \"textDirection\", \n// \"textRotation\", \n// \"angleTextCounterclockwise\", \n// \"angleTextClockwise\", \n// \"rotateTextUp\", \n// \"rotateTextDown\", \n// \"verticalText\", \n// \"fill\", \n// \"border\", \n// \"borderColor\", \n// \"borderStyle\", \n// \"leftBorder\", \"rightBorder\", \"topBorder\", \"bottomBorder\", \"diagonalBorder\", \n// \"leftBorderColor\", \"rightBorderColor\", \"topBorderColor\", \"bottomBorderColor\", \"diagonalBorderColor\", \n// \"leftBorderStyle\", \"rightBorderStyle\", \"topBorderStyle\", \"bottomBorderStyle\", \"diagonalBorderStyle\", \n// \"diagonalBorderDirection\", \n// \"numberFormat\"\n// ];\n\nlet _RichText = null;\n\n/**\n * `xslx-populate` library based accessor to a given Excel workbook. All these methods are internally used by {@link XlsxDataFill}, \n * but can be used as a reference for implementing custom spreadsheet accessors.\n */\nclass XlsxPopulateAccess {\n /**\n * Constructs a new instance of XlsxSmartTemplate with given options.\n * @param {Workbook} workbook - The workbook to be accessed.\n * @param {XlsxPopulate} XlsxPopulate - The actual xlsx-populate library object.\n * @description The `XlsxPopulate` object need to be passed in order to extract\n * certain information from it, _without_ referring the whole library, thus\n * avoiding making the `xlsx-datafill` package a dependency.\n */\n constructor(workbook, XlsxPopulate) {\n this._workbook = workbook;\n this._rowSizes = {};\n this._colSizes = {};\n \n _RichText = XlsxPopulate.RichText;\n }\n\n /**\n * Returns the configured workbook for direct XlsxPopulate manipulation.\n * @returns {Workbook} The workbook involved.\n */\n workbook() {\n return this._workbook; \n }\n\n /**\n * Gets the textual representation of the cell value.\n * @param {Cell} cell - The cell to retrieve the value from.\n * @returns {string} The textual representation of cell's contents.\n */\n cellValue(cell) {\n const theValue = cell.value();\n return theValue instanceof _RichText ? theValue.text() : theValue;\n }\n\n /**\n * Sets the cell value.\n * @param {Cell} cell - The cell to retrieve the value from.\n * @param {*} value - The requested value for setting.\n * @returns {XlsxPopulateAccess} Either the requested value or chainable this.\n */\n setCellValue(cell, value) {\n cell.value(value);\n return this;\n }\n\n /**\n * Gets the textual representation of the cell value.\n * @param {Cell} cell - The cell to retrieve the value from.\n * @returns {string} The type of the cell - 'formula', 'richtext', \n * 'text', 'number', 'date', 'hyperlink', or 'unknown';\n */\n cellType(cell) {\n if (cell.formula())\n return 'formula';\n else if (cell.hyperlink())\n return 'hyperlink';\n \n const theValue = cell.value();\n if (theValue instanceof _RichText)\n return 'richtext';\n else if (theValue instanceof Date)\n return 'date';\n else \n return typeof theValue;\n }\n\n /**\n * Sets the formula in the cell\n * @param {Cell} cell - The cell to retrieve the value from.\n * @param {string} formula - the text of the formula to be set.\n * @returns {XlsxPopulateAccess} For chaining.\n */\n setCellFormula(cell, formula) {\n cell.formula(_.trimStart(formula, ' ='));\n return this;\n }\n\n /**\n * Measures the distance, as a vector between two given cells.\n * @param {Cell} from The first cell.\n * @param {Cell} to The second cell.\n * @returns {Array.} An array with two values [, ], representing the distance between the two cells.\n */\n cellDistance(from, to) {\n return [\n to.rowNumber() - from.rowNumber(),\n to.columnNumber() - from.columnNumber()\n ];\n }\n\n /**\n * Determines the size of cell, taking into account if it is part of a merged range.\n * @param {Cell} cell The cell to be investigated.\n * @returns {Array.} An array with two values [, ], representing the occupied size.\n */\n cellSize(cell) {\n const cellAddr = cell.address();\n let theSize = [1, 1];\n \n _.forEach(cell.sheet()._mergeCells, range => {\n const rangeAddr = range.attributes.ref.split(\":\");\n if (rangeAddr[0] == cellAddr) {\n theSize = this.cellDistance(cell, cell.sheet().cell(rangeAddr[1]));\n ++theSize[0];\n ++theSize[1];\n return false;\n }\n });\n \n return theSize;\n }\n\n /**\n * Sets a named style of a given cell.\n * @param {Cell} cell The cell to be operated.\n * @param {string} name The name of the style property to be set.\n * @param {string|object} value The value for this property to be set.\n * @returns {XlsxPopulateAccess} For invocation chaining.\n */\n setCellStyle(cell, name, value) {\n cell.style(name, value);\n return this;\n }\n\n /**\n * Creates a reference Id for a given cell, based on its sheet and address.\n * @param {Cell} cell The cell to create a reference Id to.\n * @param {boolean} withSheet Whether to include the sheet name in the reference. Defaults to true.\n * @returns {string} The id to be used as a reference for this cell.\n */\n cellRef(cell, withSheet) {\n if (withSheet == null)\n withSheet = true;\n return cell.address({ includeSheetName: withSheet });\n }\n\n /**\n * Build a reference string for a cell identified by @param adr, from the @param cell.\n * @param {Cell} cell A cell that is a base of the reference.\n * @param {string} adr The address of the target cell, as mentioned in @param cell.\n * @param {boolean} withSheet Whether to include the sheet name in the reference. Defaults to true.\n * @returns {string} A reference string identifying the target cell uniquely.\n */\n buildRef(cell, adr, withSheet) {\n if (withSheet == null)\n withSheet = true;\n return adr ? cell.sheet().cell(adr).address({ includeSheetName: withSheet }) : null;\n }\n\n /**\n * Retrieves a given cell from a given sheet (or an active one).\n * @param {string|object|array} address The cell adress to be used\n * @param {string|idx} sheetId The id/name of the sheet to retrieve the cell from. Defaults to an active one.\n * @returns {Cell} A reference to the required cell.\n */\n getCell(address, sheetId) {\n const theSheet = sheetId == null ? this._workbook.activeSheet() : this._workbook.sheet(sheetId);\n return theSheet.cell(address);\n }\n\n /**\n * Duplicates a cell across a given range.\n * @param {Cell} cell Cell, which needs duplicating.\n * @param {Range} range The range, as returned from {@link getCellRange}\n * @returns {XlsxPopulateAccess} For chain invokes.\n */\n duplicateCell(cell, range) {\n range.value(cell.value());\n return this;\n }\n\n /**\n * Constructs and returns the range starting from the given cell and spawning given rows and cells.\n * @param {Cell} cell The starting cell of the range.\n * @param {Number} rowOffset Number of rows away from the starting cell. 0 means same row.\n * @param {Number} colOffset Number of columns away from the starting cell. 0 means same column.\n * @returns {Range} The constructed range.\n */\n getCellRange(cell, rowOffset, colOffset) {\n return cell.rangeTo(cell.relativeCell(rowOffset, colOffset));\n }\n\n /**\n * Gets the cell at a certain offset from a given one.\n * @param {Cell} cell The reference cell to make the offset from.\n * @param {int} rows Number of rows to offset.\n * @param {int} cols Number of columns to offset.\n * @returns {Cell} The resulting cell.\n */\n offsetCell(cell, rows, cols) {\n return cell.relativeCell(rows, cols);\n }\n\n /**\n * Merge or split range of cells.\n * @param {Range} range The range, as returned from {@link getCellRange}\n * @param {boolean} status The merged status to be set.\n * @returns {XlsxPopulateAccess} For chain invokes.\n */\n rangeMerged(range, status) {\n if (status === undefined)\n return range.merged();\n else {\n range.merged(status);\n return this;\n }\n }\n\n /**\n * Sets a formula for the whole range. If it contains only one - it is set directly.\n * @param {Range} range The range, as returned from {@link getCellRange}\n * @param {String} formula The formula to be set.\n * @returns {XlsxPopulateAccess} For chain invokes.\n */\n setRangeFormula(range, formula) {\n range.formula(_.trimStart(formula, ' ='));\n return this;\n }\n\n /**\n * Return the string representation of a given range.\n * @param {Range} range The range which address we're interested in.\n * @param {boolean} withSheet Whether to include sheet name in the address.\n * @return {String} The string, representing the given range.\n */\n rangeRef(range, withSheet) {\n if (withSheet == null)\n withSheet = true;\n return range.address({ includeSheetName: withSheet });\n }\n\n /**\n * Iterate over all used cells of the given workbook.\n * @param {function} cb The callback to be invoked with `cell` argument for each used cell.\n * @returns {XlsxPopulateAccess} For chain invokes.\n */\n forAllCells(cb) {\n this._workbook.sheets().forEach(sheet => {\n const theRange = sheet.usedRange();\n if (theRange) \n theRange.forEach(cb);\n });\n return this;\n }\n\n /**\n * Copies the styles from `src` cell to the `dest`-ination one.\n * @param {Cell} dest Destination cell.\n * @param {Cell} src Source cell.\n * @returns {XlsxPopulateAccess} For invocation chaining.\n */\n copyStyle(dest, src) {\n if (!src || !dest) throw new Error(\"Crash! Null 'src' or 'dest' for copyStyle()!\");\n if (src == dest) return this;\n\n if (src._style !== undefined)\n dest.style(src._style);\n else if (src._styleId > 0)\n dest._styleId = src._styleId;\n\n const destSheetId = dest.sheet().name(),\n rowId = `'${destSheetId}':${dest.rowNumber()}`,\n colId = `'${destSheetId}':${dest.columnNumber()}`;\n\n if (this._rowSizes[rowId] === undefined)\n dest.row().height(this._rowSizes[rowId] = src.row().height());\n \n if (this._colSizes[colId] === undefined)\n dest.column().width(this._colSizes[colId] = src.column().width());\n\n return this;\n }\n}\n\nmodule.exports = XlsxPopulateAccess;\n"]} \ No newline at end of file diff --git a/src/XlsxDataFill.js b/src/XlsxDataFill.js index c1f08e7..def07a8 100644 --- a/src/XlsxDataFill.js +++ b/src/XlsxDataFill.js @@ -26,19 +26,14 @@ class XlsxDataFill { * Constructs a new instance of XlsxDataFill with given options. * @param {object} accessor An instance of XLSX spreadsheet accessing class. * @param {{}} opts Options to be used during processing. - * @param {RegExp} opts.templateRegExp The regular expression to be used for template recognizing. - * Default is `/\{\{([^}]*)\}\}/`, i.e. Mustache. - * @param {string} opts.fieldSplitter The string to be expected as template field splitter. Default is `|`. - * @param {string} opts.joinText The string to be used when the extracted value for a single cell is an array, - * and it needs to be joined. Default is `,`. - * @param {string|boolean} opts.mergeCells Whether to merge the higher dimension cells in the output. Default is true. - * @param {string|boolean} opts.duplicateCells Whether to duplicate the content of higher dimension cells, when not merged. Default is false. - * @param {boolean} opts.followFormulae If a template is located as a result of a formula, whether to still process it. - * Default is false. - * @param {boolean} opts.copyStyle Copy the style of the template cell when populating. Even when `false`, the template - * styling _is_ applied. Default is true. + * @param {RegExp} opts.templateRegExp The regular expression to be used for template recognizing. Default is `/\{\{([^}]*)\}\}/`, i.e. Mustache. + * @param {string|RegExo} opts.fieldSplitter The string or regular expression to be used as template fields splitter. Default is `|`. + * @param {string} opts.joinText The string to be used when the extracted value for a single cell is an array, and it needs to be joined. Default is `,`. + * @param {string|boolean} opts.mergeCells Whether to merge the higher dimension cells in the output. Default is true, but valid values are also `"both"`, `"vertical"` and `"horizontal"`. + * @param {string|boolean} opts.duplicateCells Whether to duplicate the content of higher dimension cells, when not merged. Default is false. Same valud values as `mergeCells`. + * @param {boolean} opts.followFormulae If a template is located as a result of a formula, whether to still process it. Default is false. + * @param {boolean} opts.copyStyle Copy the style of the template cell when populating. Even when `false`, the template styling _is_ applied. Default is true. * @param {object.} opts.callbacksMap A map of handlers to be used for data and value extraction. - * There is one default - the empty one, for object key extraction. */ constructor(accessor, opts) { this._opts = _.defaultsDeep({}, opts, defaultOpts); @@ -49,8 +44,7 @@ class XlsxDataFill { /** * Setter/getter for XlsxDataFill's options as set during construction. - * @param {{}|null} newOpts If set - the new options to be used. - * @see {@constructor}. + * @param {{}|null} newOpts If set - the new options to be used. Check [up here]{@link #new-xlsxdatafillaccessor-opts}. * @returns {XlsxDataFill|{}} The required options (in getter mode) or XlsxDataFill (in setter mode) for chaining. */ options(newOpts) {