@leankylin-sheet/excel 5.2.56 → 5.2.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -5086,7 +5086,7 @@ var getVariable = function getVariable(variables, sheetId, name) {
5086
5086
  var replaceVariablesInFormula = function replaceVariablesInFormula(formula, variables, sheetId) {
5087
5087
  if (_.isNil(variables)) return formula;
5088
5088
  return formula.replace(/\{\{(.*?)\}\}/g, function (match) {
5089
- var value = getVariable(variables, sheetId, match);
5089
+ var value = getVariable(variables, sheetId, match) || 0;
5090
5090
  if (_.isNil(value)) return match;
5091
5091
  if (typeof value === "string") return "\"".concat(value.replace(/"/g, '""'), "\"");
5092
5092
  if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
@@ -5173,6 +5173,9 @@ var setStyleAndValue = function setStyleAndValue(table, worksheet, variables) {
5173
5173
  var fa = getFa();
5174
5174
  if (fa) numFmt = fa;
5175
5175
  }
5176
+ if (["", undefined, null].includes(cell.v)) {
5177
+ v = cell.v;
5178
+ }
5176
5179
  } else if (cell.ct && ctT === "d") {
5177
5180
  var mockDate = isTime(cell.ct.fa) ? "2000-01-01 " : "";
5178
5181
  v = new Date(mockDate + cell.m);
@@ -5183,15 +5186,10 @@ var setStyleAndValue = function setStyleAndValue(table, worksheet, variables) {
5183
5186
  }
5184
5187
  if (cell.f && _typeof(v) !== "object") {
5185
5188
  var formulaStr = cell.f.startsWith("=") ? cell.f.slice(1) : cell.f;
5186
- var hasVariables = cell.f.includes("{{");
5187
- if (hasVariables) {
5188
- value = v;
5189
- } else {
5190
- value = {
5191
- formula: replaceVariablesInFormula(formulaStr, variables, table.id),
5192
- result: v
5193
- };
5194
- }
5189
+ value = {
5190
+ formula: replaceVariablesInFormula(formulaStr, variables, table.id),
5191
+ result: v
5192
+ };
5195
5193
  } else {
5196
5194
  value = v;
5197
5195
  }
package/dist/index.js CHANGED
@@ -5098,7 +5098,7 @@ var getVariable = function getVariable(variables, sheetId, name) {
5098
5098
  var replaceVariablesInFormula = function replaceVariablesInFormula(formula, variables, sheetId) {
5099
5099
  if (___default['default'].isNil(variables)) return formula;
5100
5100
  return formula.replace(/\{\{(.*?)\}\}/g, function (match) {
5101
- var value = getVariable(variables, sheetId, match);
5101
+ var value = getVariable(variables, sheetId, match) || 0;
5102
5102
  if (___default['default'].isNil(value)) return match;
5103
5103
  if (typeof value === "string") return "\"".concat(value.replace(/"/g, '""'), "\"");
5104
5104
  if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
@@ -5185,6 +5185,9 @@ var setStyleAndValue = function setStyleAndValue(table, worksheet, variables) {
5185
5185
  var fa = getFa();
5186
5186
  if (fa) numFmt = fa;
5187
5187
  }
5188
+ if (["", undefined, null].includes(cell.v)) {
5189
+ v = cell.v;
5190
+ }
5188
5191
  } else if (cell.ct && ctT === "d") {
5189
5192
  var mockDate = isTime(cell.ct.fa) ? "2000-01-01 " : "";
5190
5193
  v = new Date(mockDate + cell.m);
@@ -5195,15 +5198,10 @@ var setStyleAndValue = function setStyleAndValue(table, worksheet, variables) {
5195
5198
  }
5196
5199
  if (cell.f && _typeof(v) !== "object") {
5197
5200
  var formulaStr = cell.f.startsWith("=") ? cell.f.slice(1) : cell.f;
5198
- var hasVariables = cell.f.includes("{{");
5199
- if (hasVariables) {
5200
- value = v;
5201
- } else {
5202
- value = {
5203
- formula: replaceVariablesInFormula(formulaStr, variables, table.id),
5204
- result: v
5205
- };
5206
- }
5201
+ value = {
5202
+ formula: replaceVariablesInFormula(formulaStr, variables, table.id),
5203
+ result: v
5204
+ };
5207
5205
  } else {
5208
5206
  value = v;
5209
5207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leankylin-sheet/excel",
3
- "version": "5.2.56",
3
+ "version": "5.2.58",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.esm.js",