@vdhewei/xlsx-template-lib 1.3.4 → 1.3.5

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.mjs CHANGED
@@ -3051,6 +3051,29 @@ var toCellRow = (rowVals, setup) => {
3051
3051
  var toCellColumn = (columnVals, setup) => {
3052
3052
  return toCellRow(columnVals, setup);
3053
3053
  };
3054
+ var toCellValue = (value) => {
3055
+ if (typeof value !== "string") {
3056
+ const rText = value;
3057
+ if (rText !== void 0 && rText.richText !== void 0 && rText.richText.length > 0) {
3058
+ const values = [];
3059
+ for (const [_, v] of rText.richText.entries()) {
3060
+ if (v === void 0 || v === null) {
3061
+ continue;
3062
+ }
3063
+ const text = v.text !== void 0 && v.text !== null ? v.text : void 0;
3064
+ if (text !== void 0 && text !== "" && text !== "[object]") {
3065
+ values.push(text.trim());
3066
+ }
3067
+ }
3068
+ return values.join(" ");
3069
+ }
3070
+ const hText = value;
3071
+ if (hText !== void 0 && hText.text !== null && hText.hyperlink !== null) {
3072
+ return `[${hText.text}](${hText.hyperlink})`;
3073
+ }
3074
+ }
3075
+ return value.toString();
3076
+ };
3054
3077
  var resolveCompileMacroExpr = (ctx, macroExpr, macroTokens2, currentCellIndex, totalCells) => {
3055
3078
  if (macroTokens2 === void 0 || macroTokens2.length <= 0) {
3056
3079
  return macroExpr;
@@ -3107,8 +3130,9 @@ var resolveCompileMacroExpr = (ctx, macroExpr, macroTokens2, currentCellIndex, t
3107
3130
  if (cellValue === void 0 || cellValue.value === null) {
3108
3131
  return;
3109
3132
  }
3110
- const value = execMacroFormat(cellValue.value.toString(), formatter);
3111
- parts.push(value);
3133
+ const value = toCellValue(cellValue.value);
3134
+ let exprValue2 = execMacroFormat(value, formatter);
3135
+ parts.push(exprValue2);
3112
3136
  });
3113
3137
  });
3114
3138
  }
@@ -3995,6 +4019,7 @@ export {
3995
4019
  resolveArgument,
3996
4020
  scanCellSetPlaceholder,
3997
4021
  toArrayBuffer,
4022
+ toCellValue,
3998
4023
  valueDotGet,
3999
4024
  workSheetSetPlaceholder
4000
4025
  };