@vdhewei/xlsx-template-lib 1.4.2 → 1.5.0
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.js +16 -6
- package/dist/bin.js.map +1 -1
- package/dist/bin.mjs +1 -1
- package/dist/{chunk-XYVHFW4V.mjs → chunk-TC2FHOAF.mjs} +180 -8
- package/dist/chunk-TC2FHOAF.mjs.map +1 -0
- package/dist/index.d.mts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.js +181 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/package.json +6 -2
- package/dist/chunk-XYVHFW4V.mjs.map +0 -1
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 & {
|
|
@@ -470,5 +470,35 @@ declare const compileRuleSheetName = "export_metadata.config";
|
|
|
470
470
|
declare const mergeMap: (source: Map<string, string>, dest: Map<string, string>) => Map<string, string>;
|
|
471
471
|
declare const autoRegisterAlias: (values: Object, configure: RuleResult) => Object;
|
|
472
472
|
declare const generateCommandsXlsxTemplateWithCompile: <T extends JsZip.OutputType>(data: Buffer, values: Object, compileOptions: AutoOptions, options?: JsZip.JSZipGeneratorOptions<T> & FullOptions) => Promise<OutputByType[T]>;
|
|
473
|
+
declare const compileAll: (buf: Buffer, compileOpts: AutoOptions, renderData?: Object) => Promise<Buffer>;
|
|
473
474
|
|
|
474
|
-
|
|
475
|
+
type CustomChecker = (data: Buffer, options: FullOptions & {
|
|
476
|
+
[key: string]: any;
|
|
477
|
+
}, values: Object, fileName?: string) => Promise<Buffer>;
|
|
478
|
+
type CustomCheckerOptions = {
|
|
479
|
+
checker?: CustomChecker;
|
|
480
|
+
options?: FullOptions;
|
|
481
|
+
[key: string]: any;
|
|
482
|
+
};
|
|
483
|
+
declare class XlsxRender extends Workbook {
|
|
484
|
+
constructor(option?: FullOptions);
|
|
485
|
+
static create(data: Buffer, option?: FullOptions): Promise<XlsxRender>;
|
|
486
|
+
render(values: Object, sheetName: string): Promise<void>;
|
|
487
|
+
getSheets(): SheetInfo[];
|
|
488
|
+
}
|
|
489
|
+
declare class ZipXlsxTemplateApp {
|
|
490
|
+
zipBuffer?: Buffer;
|
|
491
|
+
private zip;
|
|
492
|
+
private xlsxEntries;
|
|
493
|
+
private records;
|
|
494
|
+
constructor(data?: Buffer);
|
|
495
|
+
loadZipBuffer(data: Buffer): ZipXlsxTemplateApp;
|
|
496
|
+
parse(data: Buffer): Map<string, Buffer>;
|
|
497
|
+
getEntries(): Map<string, Buffer>;
|
|
498
|
+
static compileAll(files: Map<string, Buffer>, renderData?: Object, compileOpts?: AutoOptions): Promise<Map<string, Buffer>>;
|
|
499
|
+
substituteAll(renderData: Object, compileOpts?: AutoOptions, renderOpts?: FullOptions): Promise<ZipXlsxTemplateApp>;
|
|
500
|
+
generate(options?: JsZip.JSZipGeneratorOptions<BufferType.NodeBuffer> & FullOptions): Promise<Buffer>;
|
|
501
|
+
static compileTo(data: Buffer, opts: CustomCheckerOptions, values?: Record<string, any> | Object): Promise<Buffer>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export { AddCommand, AddCommandMust, type AfterReplaceHook, type Argument, ArgumentData, ArgumentValue, ArgumentValueLoader, type AutoOptions, type BeforeReplaceHook, BufferType, type CellPosition, type CmdFunction, CompileContext, type CompileResult, type CustomChecker, type CustomFormatter, type CustomPlaceholderExtractor, type CustomReplacer, DefaultPlaceholderCellValue, type DrawingInfo, ExprResolver, type ExtensionOptions, type ExtractMacroArgs, type FilterMacroResult, type FullOptions, type MacroArgs, type MacroUnitHelper, type OutputByType, type Placeholder, type PlaceholderCellValue, type QueryFunction, type Range, type Ref, type RelsInfo, RuleMapOptions, type RuleOptions, type RuleResult, RuleToken, type SheetInfo, type TableInfo, TokenParserManger, Workbook, type WorkbookOptions, XlsxRender, ZipXlsxTemplateApp, autoRegisterAlias, columnLetterToNumber, columnNumberToLetter, commandExtendQuery, compileAll, compileRuleSheetName, compileWorkSheet, compileWorkSheetPlaceholder, defaultExtractPlaceholders, defaultFormatters, defaultValueDotGet, generateCommandsXlsxTemplate, generateCommandsXlsxTemplateWithCompile, generateXlsxTemplate, getCommands, getTokenParser, hasGeneratorToken, isRuleToken, isUrl, loadCompileSheets, loadWorkbook, mergeMap, parseWorkSheetRules, registerTokenParser, registerTokenParserMust, resolveArgument, scanCellSetPlaceholder, toArrayBuffer, toCellValue, valueDotGet, workSheetSetPlaceholder };
|
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 & {
|
|
@@ -470,5 +470,35 @@ declare const compileRuleSheetName = "export_metadata.config";
|
|
|
470
470
|
declare const mergeMap: (source: Map<string, string>, dest: Map<string, string>) => Map<string, string>;
|
|
471
471
|
declare const autoRegisterAlias: (values: Object, configure: RuleResult) => Object;
|
|
472
472
|
declare const generateCommandsXlsxTemplateWithCompile: <T extends JsZip.OutputType>(data: Buffer, values: Object, compileOptions: AutoOptions, options?: JsZip.JSZipGeneratorOptions<T> & FullOptions) => Promise<OutputByType[T]>;
|
|
473
|
+
declare const compileAll: (buf: Buffer, compileOpts: AutoOptions, renderData?: Object) => Promise<Buffer>;
|
|
473
474
|
|
|
474
|
-
|
|
475
|
+
type CustomChecker = (data: Buffer, options: FullOptions & {
|
|
476
|
+
[key: string]: any;
|
|
477
|
+
}, values: Object, fileName?: string) => Promise<Buffer>;
|
|
478
|
+
type CustomCheckerOptions = {
|
|
479
|
+
checker?: CustomChecker;
|
|
480
|
+
options?: FullOptions;
|
|
481
|
+
[key: string]: any;
|
|
482
|
+
};
|
|
483
|
+
declare class XlsxRender extends Workbook {
|
|
484
|
+
constructor(option?: FullOptions);
|
|
485
|
+
static create(data: Buffer, option?: FullOptions): Promise<XlsxRender>;
|
|
486
|
+
render(values: Object, sheetName: string): Promise<void>;
|
|
487
|
+
getSheets(): SheetInfo[];
|
|
488
|
+
}
|
|
489
|
+
declare class ZipXlsxTemplateApp {
|
|
490
|
+
zipBuffer?: Buffer;
|
|
491
|
+
private zip;
|
|
492
|
+
private xlsxEntries;
|
|
493
|
+
private records;
|
|
494
|
+
constructor(data?: Buffer);
|
|
495
|
+
loadZipBuffer(data: Buffer): ZipXlsxTemplateApp;
|
|
496
|
+
parse(data: Buffer): Map<string, Buffer>;
|
|
497
|
+
getEntries(): Map<string, Buffer>;
|
|
498
|
+
static compileAll(files: Map<string, Buffer>, renderData?: Object, compileOpts?: AutoOptions): Promise<Map<string, Buffer>>;
|
|
499
|
+
substituteAll(renderData: Object, compileOpts?: AutoOptions, renderOpts?: FullOptions): Promise<ZipXlsxTemplateApp>;
|
|
500
|
+
generate(options?: JsZip.JSZipGeneratorOptions<BufferType.NodeBuffer> & FullOptions): Promise<Buffer>;
|
|
501
|
+
static compileTo(data: Buffer, opts: CustomCheckerOptions, values?: Record<string, any> | Object): Promise<Buffer>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export { AddCommand, AddCommandMust, type AfterReplaceHook, type Argument, ArgumentData, ArgumentValue, ArgumentValueLoader, type AutoOptions, type BeforeReplaceHook, BufferType, type CellPosition, type CmdFunction, CompileContext, type CompileResult, type CustomChecker, type CustomFormatter, type CustomPlaceholderExtractor, type CustomReplacer, DefaultPlaceholderCellValue, type DrawingInfo, ExprResolver, type ExtensionOptions, type ExtractMacroArgs, type FilterMacroResult, type FullOptions, type MacroArgs, type MacroUnitHelper, type OutputByType, type Placeholder, type PlaceholderCellValue, type QueryFunction, type Range, type Ref, type RelsInfo, RuleMapOptions, type RuleOptions, type RuleResult, RuleToken, type SheetInfo, type TableInfo, TokenParserManger, Workbook, type WorkbookOptions, XlsxRender, ZipXlsxTemplateApp, autoRegisterAlias, columnLetterToNumber, columnNumberToLetter, commandExtendQuery, compileAll, compileRuleSheetName, compileWorkSheet, compileWorkSheetPlaceholder, defaultExtractPlaceholders, defaultFormatters, defaultValueDotGet, generateCommandsXlsxTemplate, generateCommandsXlsxTemplateWithCompile, generateXlsxTemplate, getCommands, getTokenParser, hasGeneratorToken, isRuleToken, isUrl, loadCompileSheets, loadWorkbook, mergeMap, parseWorkSheetRules, registerTokenParser, registerTokenParserMust, resolveArgument, scanCellSetPlaceholder, toArrayBuffer, toCellValue, valueDotGet, workSheetSetPlaceholder };
|
package/dist/index.js
CHANGED
|
@@ -43,10 +43,13 @@ __export(index_exports, {
|
|
|
43
43
|
RuleToken: () => RuleToken,
|
|
44
44
|
TokenParserManger: () => TokenParserManger,
|
|
45
45
|
Workbook: () => Workbook,
|
|
46
|
+
XlsxRender: () => XlsxRender,
|
|
47
|
+
ZipXlsxTemplateApp: () => ZipXlsxTemplateApp,
|
|
46
48
|
autoRegisterAlias: () => autoRegisterAlias,
|
|
47
49
|
columnLetterToNumber: () => columnLetterToNumber,
|
|
48
50
|
columnNumberToLetter: () => columnNumberToLetter,
|
|
49
51
|
commandExtendQuery: () => commandExtendQuery,
|
|
52
|
+
compileAll: () => compileAll,
|
|
50
53
|
compileRuleSheetName: () => compileRuleSheetName,
|
|
51
54
|
compileWorkSheet: () => compileWorkSheet,
|
|
52
55
|
compileWorkSheetPlaceholder: () => compileWorkSheetPlaceholder,
|
|
@@ -3076,7 +3079,7 @@ var extractMacro = function(expr, options) {
|
|
|
3076
3079
|
}
|
|
3077
3080
|
return extracResult;
|
|
3078
3081
|
};
|
|
3079
|
-
var __codeKey = (str) => {
|
|
3082
|
+
var __codeKey = (str, expr) => {
|
|
3080
3083
|
const replaces = [" ", `-`, `/`, `,`, `'`, `&`, `.`, `(`, `)`, `{`, `}`, `@`, `\\`, `[`, `]`, `#`, `:`];
|
|
3081
3084
|
for (const k of replaces) {
|
|
3082
3085
|
str = str.replaceAll(k, "_").trim();
|
|
@@ -3092,12 +3095,15 @@ var __codeKey = (str) => {
|
|
|
3092
3095
|
}
|
|
3093
3096
|
return str.toUpperCase();
|
|
3094
3097
|
};
|
|
3095
|
-
var __numberKey = (str) => {
|
|
3098
|
+
var __numberKey = (str, expr) => {
|
|
3096
3099
|
return Number.parseInt(str, 10).toString();
|
|
3097
3100
|
};
|
|
3098
|
-
var __codeAliasKey = (str) => {
|
|
3101
|
+
var __codeAliasKey = (str, expr) => {
|
|
3099
3102
|
const key = __codeKey(str);
|
|
3100
3103
|
if (key !== "") {
|
|
3104
|
+
if (expr !== void 0 && expr.tokens.length > 0) {
|
|
3105
|
+
expr.tokens.push("@" /* UseAliasToken */);
|
|
3106
|
+
}
|
|
3101
3107
|
return `${defaultRuleTokenMap.get("@" /* UseAliasToken */)}${key}`;
|
|
3102
3108
|
}
|
|
3103
3109
|
return "";
|
|
@@ -3108,11 +3114,11 @@ var macroFormatter = /* @__PURE__ */ new Map([
|
|
|
3108
3114
|
[codeAliasKey, __codeAliasKey],
|
|
3109
3115
|
[defaultKey, (v) => v]
|
|
3110
3116
|
]);
|
|
3111
|
-
var execMacroFormat = function(value, formatter) {
|
|
3117
|
+
var execMacroFormat = function(value, formatter, expr) {
|
|
3112
3118
|
if (!macroFormatter.has(formatter)) {
|
|
3113
3119
|
return value;
|
|
3114
3120
|
}
|
|
3115
|
-
return macroFormatter.get(formatter)(value);
|
|
3121
|
+
return macroFormatter.get(formatter)(value, expr);
|
|
3116
3122
|
};
|
|
3117
3123
|
var toCellRow = (rowVals, setup) => {
|
|
3118
3124
|
if (setup === void 0) {
|
|
@@ -3210,7 +3216,7 @@ var resolveCompileMacroExpr = (ctx, macroExpr, macroTokens2, currentCellIndex, t
|
|
|
3210
3216
|
return;
|
|
3211
3217
|
}
|
|
3212
3218
|
const value = toCellValue(cellValue.value);
|
|
3213
|
-
let exprValue2 = execMacroFormat(value, formatter);
|
|
3219
|
+
let exprValue2 = execMacroFormat(value, formatter, ctx.currentExpr || void 0);
|
|
3214
3220
|
parts.push(exprValue2);
|
|
3215
3221
|
});
|
|
3216
3222
|
});
|
|
@@ -3238,6 +3244,8 @@ var resolveCompileMacroExpr = (ctx, macroExpr, macroTokens2, currentCellIndex, t
|
|
|
3238
3244
|
exprValue = resolveCompileMacroGen(ctx, macroCurrent, currentCellIndex);
|
|
3239
3245
|
}
|
|
3240
3246
|
macroExpr = exprValue;
|
|
3247
|
+
} else {
|
|
3248
|
+
macroExpr = resolveAliasExpr(ctx, macroExpr, currentCellIndex);
|
|
3241
3249
|
}
|
|
3242
3250
|
return macroExpr;
|
|
3243
3251
|
};
|
|
@@ -4056,6 +4064,170 @@ var generateCommandsXlsxTemplateWithCompile = async function(data, values, compi
|
|
|
4056
4064
|
await w.substituteAll(values);
|
|
4057
4065
|
return w.generate(options);
|
|
4058
4066
|
};
|
|
4067
|
+
var compileAll = async (buf, compileOpts, renderData) => {
|
|
4068
|
+
if (compileOpts === void 0 || compileOpts.sheetName === "") {
|
|
4069
|
+
return buf;
|
|
4070
|
+
}
|
|
4071
|
+
const result = await ExprResolver.compile(buf, compileOpts.sheetName, compileOpts);
|
|
4072
|
+
if (result.errs !== void 0 && result.errs.length > 0) {
|
|
4073
|
+
throw result.errs[0];
|
|
4074
|
+
}
|
|
4075
|
+
if (compileOpts.remove !== void 0 && compileOpts.remove === true) {
|
|
4076
|
+
result.workbook = ExprResolver.removeUnExportSheets(result.workbook, compileOpts);
|
|
4077
|
+
}
|
|
4078
|
+
if (renderData !== void 0) {
|
|
4079
|
+
autoRegisterAlias(renderData, result.configure);
|
|
4080
|
+
}
|
|
4081
|
+
return await ExprResolver.toBuffer(result.workbook);
|
|
4082
|
+
};
|
|
4083
|
+
|
|
4084
|
+
// src/biz.ts
|
|
4085
|
+
var import_node_path = require("path");
|
|
4086
|
+
var import_lodash = require("lodash");
|
|
4087
|
+
var import_adm_zip = __toESM(require("adm-zip"));
|
|
4088
|
+
var XlsxRender = class _XlsxRender extends Workbook {
|
|
4089
|
+
constructor(option) {
|
|
4090
|
+
super(option);
|
|
4091
|
+
}
|
|
4092
|
+
static async create(data, option) {
|
|
4093
|
+
const w = await super.parse(data, option);
|
|
4094
|
+
w.setQueryFunctionHandler(commandExtendQuery);
|
|
4095
|
+
const app = new _XlsxRender(option);
|
|
4096
|
+
Object.assign(app, { ...w });
|
|
4097
|
+
return app;
|
|
4098
|
+
}
|
|
4099
|
+
async render(values, sheetName) {
|
|
4100
|
+
await this.substitute(sheetName, values);
|
|
4101
|
+
}
|
|
4102
|
+
getSheets() {
|
|
4103
|
+
return this.sheets;
|
|
4104
|
+
}
|
|
4105
|
+
};
|
|
4106
|
+
var ZipXlsxTemplateApp = class _ZipXlsxTemplateApp {
|
|
4107
|
+
constructor(data) {
|
|
4108
|
+
this.records = /* @__PURE__ */ new Map();
|
|
4109
|
+
this.zipBuffer = data;
|
|
4110
|
+
if (data !== void 0) {
|
|
4111
|
+
this.xlsxEntries = this.parse(data);
|
|
4112
|
+
}
|
|
4113
|
+
}
|
|
4114
|
+
loadZipBuffer(data) {
|
|
4115
|
+
this.zipBuffer = data;
|
|
4116
|
+
this.zip = new import_adm_zip.default(data);
|
|
4117
|
+
this.xlsxEntries = this.parse(data);
|
|
4118
|
+
return this;
|
|
4119
|
+
}
|
|
4120
|
+
parse(data) {
|
|
4121
|
+
const zip = new import_adm_zip.default(data);
|
|
4122
|
+
const result = /* @__PURE__ */ new Map();
|
|
4123
|
+
const entries = zip.getEntries();
|
|
4124
|
+
for (let fd of entries) {
|
|
4125
|
+
if (fd.isDirectory) {
|
|
4126
|
+
continue;
|
|
4127
|
+
}
|
|
4128
|
+
let ext = (0, import_node_path.extname)(fd.entryName).substring(1).toLowerCase();
|
|
4129
|
+
if (ext !== "xlsx") {
|
|
4130
|
+
continue;
|
|
4131
|
+
}
|
|
4132
|
+
result.set(fd.entryName, fd.getData());
|
|
4133
|
+
}
|
|
4134
|
+
this.zip = zip;
|
|
4135
|
+
return result;
|
|
4136
|
+
}
|
|
4137
|
+
getEntries() {
|
|
4138
|
+
if (this.xlsxEntries !== void 0 && this.xlsxEntries.size > 0) {
|
|
4139
|
+
return this.xlsxEntries;
|
|
4140
|
+
} else {
|
|
4141
|
+
if (this.zipBuffer !== void 0) {
|
|
4142
|
+
return this.parse(this.zipBuffer);
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
return /* @__PURE__ */ new Map();
|
|
4146
|
+
}
|
|
4147
|
+
static async compileAll(files, renderData, compileOpts) {
|
|
4148
|
+
const records = /* @__PURE__ */ new Map();
|
|
4149
|
+
if (compileOpts !== void 0 && (compileOpts.sheetName === void 0 || compileOpts.sheetName === "")) {
|
|
4150
|
+
compileOpts.sheetName = compileRuleSheetName;
|
|
4151
|
+
}
|
|
4152
|
+
let values = (0, import_lodash.clone)(renderData);
|
|
4153
|
+
for (let [key, buf] of files.entries()) {
|
|
4154
|
+
buf = await compileAll(buf, (0, import_lodash.clone)(compileOpts), (0, import_lodash.clone)(values));
|
|
4155
|
+
records.set(key, buf);
|
|
4156
|
+
}
|
|
4157
|
+
return records;
|
|
4158
|
+
}
|
|
4159
|
+
async substituteAll(renderData, compileOpts, renderOpts) {
|
|
4160
|
+
const files = await _ZipXlsxTemplateApp.compileAll(this.xlsxEntries, renderData, compileOpts);
|
|
4161
|
+
for (const [k, buf] of files.entries()) {
|
|
4162
|
+
const xlsx = await XlsxRender.create(buf, renderOpts);
|
|
4163
|
+
await xlsx.substituteAll(renderData);
|
|
4164
|
+
this.records.set(k, xlsx);
|
|
4165
|
+
}
|
|
4166
|
+
return this;
|
|
4167
|
+
}
|
|
4168
|
+
async generate(options) {
|
|
4169
|
+
if (this.records === void 0 || this.records.size <= 0) {
|
|
4170
|
+
return this.zipBuffer;
|
|
4171
|
+
}
|
|
4172
|
+
if (this.zip === void 0) {
|
|
4173
|
+
this.zip = new import_adm_zip.default();
|
|
4174
|
+
}
|
|
4175
|
+
if (options === void 0 || options === null) {
|
|
4176
|
+
options = {
|
|
4177
|
+
type: "nodebuffer" /* NodeBuffer */,
|
|
4178
|
+
compression: "DEFLATE",
|
|
4179
|
+
compressionOptions: {
|
|
4180
|
+
level: 9
|
|
4181
|
+
}
|
|
4182
|
+
};
|
|
4183
|
+
}
|
|
4184
|
+
for (const [key, xlsx] of this.records) {
|
|
4185
|
+
const buf = await xlsx.generate(options);
|
|
4186
|
+
let entry = this.zip.getEntry(key);
|
|
4187
|
+
if (entry !== null) {
|
|
4188
|
+
entry.setData(Buffer.from(buf));
|
|
4189
|
+
} else {
|
|
4190
|
+
this.zip.addFile(key, Buffer.from(buf));
|
|
4191
|
+
}
|
|
4192
|
+
}
|
|
4193
|
+
return this.zip.toBuffer();
|
|
4194
|
+
}
|
|
4195
|
+
static async compileTo(data, opts, values) {
|
|
4196
|
+
const zip = new import_adm_zip.default(data);
|
|
4197
|
+
const entries = zip.getEntries();
|
|
4198
|
+
let files = /* @__PURE__ */ new Map();
|
|
4199
|
+
if (values === void 0) {
|
|
4200
|
+
values = /* @__PURE__ */ new Map();
|
|
4201
|
+
}
|
|
4202
|
+
for (let fd of entries) {
|
|
4203
|
+
if (fd.isDirectory) {
|
|
4204
|
+
continue;
|
|
4205
|
+
}
|
|
4206
|
+
let ext = (0, import_node_path.extname)(fd.entryName).substring(1).toLowerCase();
|
|
4207
|
+
if (ext !== "xlsx") {
|
|
4208
|
+
continue;
|
|
4209
|
+
}
|
|
4210
|
+
let buf = fd.getData();
|
|
4211
|
+
if (opts.checker !== void 0) {
|
|
4212
|
+
await opts.checker(buf, opts.options, values, opts.fileName || void 0);
|
|
4213
|
+
}
|
|
4214
|
+
files.set(fd.entryName, buf);
|
|
4215
|
+
}
|
|
4216
|
+
const compileOpts = new RuleMapOptions();
|
|
4217
|
+
compileOpts.remove = true;
|
|
4218
|
+
if (files.size > 0) {
|
|
4219
|
+
files = await _ZipXlsxTemplateApp.compileAll(files, values, compileOpts);
|
|
4220
|
+
} else {
|
|
4221
|
+
throw new Error(`empty xlsx file zip file`);
|
|
4222
|
+
}
|
|
4223
|
+
if (files.size > 0) {
|
|
4224
|
+
for (const [k, data2] of files.entries()) {
|
|
4225
|
+
zip.getEntry(k).setData(data2);
|
|
4226
|
+
}
|
|
4227
|
+
}
|
|
4228
|
+
return zip.toBuffer();
|
|
4229
|
+
}
|
|
4230
|
+
};
|
|
4059
4231
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4060
4232
|
0 && (module.exports = {
|
|
4061
4233
|
AddCommand,
|
|
@@ -4071,10 +4243,13 @@ var generateCommandsXlsxTemplateWithCompile = async function(data, values, compi
|
|
|
4071
4243
|
RuleToken,
|
|
4072
4244
|
TokenParserManger,
|
|
4073
4245
|
Workbook,
|
|
4246
|
+
XlsxRender,
|
|
4247
|
+
ZipXlsxTemplateApp,
|
|
4074
4248
|
autoRegisterAlias,
|
|
4075
4249
|
columnLetterToNumber,
|
|
4076
4250
|
columnNumberToLetter,
|
|
4077
4251
|
commandExtendQuery,
|
|
4252
|
+
compileAll,
|
|
4078
4253
|
compileRuleSheetName,
|
|
4079
4254
|
compileWorkSheet,
|
|
4080
4255
|
compileWorkSheetPlaceholder,
|