@vdhewei/xlsx-template-lib 1.3.5 → 1.4.3
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/bin.d.mts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +1631 -0
- package/dist/bin.js.map +1 -0
- package/dist/bin.mjs +21 -0
- package/dist/bin.mjs.map +1 -0
- package/dist/chunk-2UQSPJKC.mjs +4032 -0
- package/dist/chunk-2UQSPJKC.mjs.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -3979
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -3
package/dist/index.d.mts
CHANGED
|
@@ -384,7 +384,7 @@ declare class TokenParserManger {
|
|
|
384
384
|
}
|
|
385
385
|
declare function columnLetterToNumber(letter: string): number;
|
|
386
386
|
declare function columnNumberToLetter(num: number): string;
|
|
387
|
-
type MacroUnitHelper = (v: string) => string;
|
|
387
|
+
type MacroUnitHelper = (v: string, expr?: RuleValue) => string;
|
|
388
388
|
declare const toCellValue: (value: exceljs.CellValue) => string;
|
|
389
389
|
declare const loadWorkbook: <T extends ArrayBuffer | Buffer | string>(data: T) => Promise<exceljs.Workbook>;
|
|
390
390
|
declare const scanCellSetPlaceholder: <T extends ArrayBuffer | Buffer | string>(excelBuffer: T, cell: CellPosition & {
|
package/dist/index.d.ts
CHANGED
|
@@ -384,7 +384,7 @@ declare class TokenParserManger {
|
|
|
384
384
|
}
|
|
385
385
|
declare function columnLetterToNumber(letter: string): number;
|
|
386
386
|
declare function columnNumberToLetter(num: number): string;
|
|
387
|
-
type MacroUnitHelper = (v: string) => string;
|
|
387
|
+
type MacroUnitHelper = (v: string, expr?: RuleValue) => string;
|
|
388
388
|
declare const toCellValue: (value: exceljs.CellValue) => string;
|
|
389
389
|
declare const loadWorkbook: <T extends ArrayBuffer | Buffer | string>(data: T) => Promise<exceljs.Workbook>;
|
|
390
390
|
declare const scanCellSetPlaceholder: <T extends ArrayBuffer | Buffer | string>(excelBuffer: T, cell: CellPosition & {
|
package/dist/index.js
CHANGED
|
@@ -3076,7 +3076,7 @@ var extractMacro = function(expr, options) {
|
|
|
3076
3076
|
}
|
|
3077
3077
|
return extracResult;
|
|
3078
3078
|
};
|
|
3079
|
-
var __codeKey = (str) => {
|
|
3079
|
+
var __codeKey = (str, expr) => {
|
|
3080
3080
|
const replaces = [" ", `-`, `/`, `,`, `'`, `&`, `.`, `(`, `)`, `{`, `}`, `@`, `\\`, `[`, `]`, `#`, `:`];
|
|
3081
3081
|
for (const k of replaces) {
|
|
3082
3082
|
str = str.replaceAll(k, "_").trim();
|
|
@@ -3092,12 +3092,15 @@ var __codeKey = (str) => {
|
|
|
3092
3092
|
}
|
|
3093
3093
|
return str.toUpperCase();
|
|
3094
3094
|
};
|
|
3095
|
-
var __numberKey = (str) => {
|
|
3095
|
+
var __numberKey = (str, expr) => {
|
|
3096
3096
|
return Number.parseInt(str, 10).toString();
|
|
3097
3097
|
};
|
|
3098
|
-
var __codeAliasKey = (str) => {
|
|
3098
|
+
var __codeAliasKey = (str, expr) => {
|
|
3099
3099
|
const key = __codeKey(str);
|
|
3100
3100
|
if (key !== "") {
|
|
3101
|
+
if (expr !== void 0 && expr.tokens.length > 0) {
|
|
3102
|
+
expr.tokens.push("@" /* UseAliasToken */);
|
|
3103
|
+
}
|
|
3101
3104
|
return `${defaultRuleTokenMap.get("@" /* UseAliasToken */)}${key}`;
|
|
3102
3105
|
}
|
|
3103
3106
|
return "";
|
|
@@ -3108,11 +3111,11 @@ var macroFormatter = /* @__PURE__ */ new Map([
|
|
|
3108
3111
|
[codeAliasKey, __codeAliasKey],
|
|
3109
3112
|
[defaultKey, (v) => v]
|
|
3110
3113
|
]);
|
|
3111
|
-
var execMacroFormat = function(value, formatter) {
|
|
3114
|
+
var execMacroFormat = function(value, formatter, expr) {
|
|
3112
3115
|
if (!macroFormatter.has(formatter)) {
|
|
3113
3116
|
return value;
|
|
3114
3117
|
}
|
|
3115
|
-
return macroFormatter.get(formatter)(value);
|
|
3118
|
+
return macroFormatter.get(formatter)(value, expr);
|
|
3116
3119
|
};
|
|
3117
3120
|
var toCellRow = (rowVals, setup) => {
|
|
3118
3121
|
if (setup === void 0) {
|
|
@@ -3210,7 +3213,7 @@ var resolveCompileMacroExpr = (ctx, macroExpr, macroTokens2, currentCellIndex, t
|
|
|
3210
3213
|
return;
|
|
3211
3214
|
}
|
|
3212
3215
|
const value = toCellValue(cellValue.value);
|
|
3213
|
-
let exprValue2 = execMacroFormat(value, formatter);
|
|
3216
|
+
let exprValue2 = execMacroFormat(value, formatter, ctx.currentExpr || void 0);
|
|
3214
3217
|
parts.push(exprValue2);
|
|
3215
3218
|
});
|
|
3216
3219
|
});
|
|
@@ -3238,6 +3241,8 @@ var resolveCompileMacroExpr = (ctx, macroExpr, macroTokens2, currentCellIndex, t
|
|
|
3238
3241
|
exprValue = resolveCompileMacroGen(ctx, macroCurrent, currentCellIndex);
|
|
3239
3242
|
}
|
|
3240
3243
|
macroExpr = exprValue;
|
|
3244
|
+
} else {
|
|
3245
|
+
macroExpr = resolveAliasExpr(ctx, macroExpr, currentCellIndex);
|
|
3241
3246
|
}
|
|
3242
3247
|
return macroExpr;
|
|
3243
3248
|
};
|
|
@@ -3698,7 +3703,7 @@ var compileWorkSheet = async function(data, sheetName, options) {
|
|
|
3698
3703
|
var fetchAlias = (m) => {
|
|
3699
3704
|
let sv;
|
|
3700
3705
|
const alias = /* @__PURE__ */ new Map();
|
|
3701
|
-
if (!(m instanceof Map) && m
|
|
3706
|
+
if (m !== void 0 && m !== null && !(m instanceof Map) && m?.rules !== void 0) {
|
|
3702
3707
|
sv = m.rules;
|
|
3703
3708
|
} else if (m instanceof Map) {
|
|
3704
3709
|
if (m.size <= 0 || !m.has("alias" /* AliasToken */)) {
|