diff --git a/dist/excel-table.amd.js b/dist/excel-table.amd.js index 1de5e2c..2fe50bc 100644 --- a/dist/excel-table.amd.js +++ b/dist/excel-table.amd.js @@ -1 +1 @@ -define(["exports","./index-DfuHK51s"],function(e,a){"use strict";e.Validator=a.validateExcelTable,e.addGlobalOptionFromExcelTable=a.addGlobalOptionFromExcelTable,e.addGlobalOptions=a.addGlobalOptions,e.convertTableToExcel=a.convertTableToExcel,e.excelToJson=a.excelToJson,e.excelToNode=a.excelToNode,e.extractExcelData=a.extractExcelData,e.generateCSV=a.generateCSV,e.generateExcel=a.generateExcel,e.generateText=a.generateText,e.replaceInExcel=a.replaceInExcel,e.sideBySideLineByLine=a.sideBySideLineByLine,e.themeBaseGenerate=a.themeBaseGenerate,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}); +define(["exports","./index-DfuHK51s"],function(e,a){"use strict";e.Validator=a.validateExcelTable,e.addGlobalOptionFromExcelTable=a.addGlobalOptionFromExcelTable,e.addGlobalOptions=a.addGlobalOptions,e.convertTableToExcel=a.convertTableToExcel,e.excelToJson=a.excelToJson,e.excelToNode=a.excelToNode,e.extractExcelData=a.extractExcelData,e.generateCSV=a.generateCSV,e.generateExcel=a.generateExcel,e.generateText=a.generateText,e.replaceInExcel=a.replaceInExcel,e.sideBySideLineByLine=a.sideBySideLineByLine,e.themeBaseGenerate=a.themeBaseGenerate,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}); \ No newline at end of file diff --git a/dist/excel-table.cjs b/dist/excel-table.cjs index 0c60a4f..05053db 100644 --- a/dist/excel-table.cjs +++ b/dist/excel-table.cjs @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DkpykvyS.cjs");exports.Validator=e.validateExcelTable;exports.addGlobalOptionFromExcelTable=e.addGlobalOptionFromExcelTable;exports.addGlobalOptions=e.addGlobalOptions;exports.convertTableToExcel=e.convertTableToExcel;exports.excelToJson=e.excelToJson;exports.excelToNode=e.excelToNode;exports.extractExcelData=e.extractExcelData;exports.generateCSV=e.generateCSV;exports.generateExcel=e.generateExcel;exports.generateText=e.generateText;exports.replaceInExcel=e.replaceInExcel;exports.sideBySideLineByLine=e.sideBySideLineByLine;exports.themeBaseGenerate=e.themeBaseGenerate; +"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DkpykvyS.cjs");exports.Validator=e.validateExcelTable;exports.addGlobalOptionFromExcelTable=e.addGlobalOptionFromExcelTable;exports.addGlobalOptions=e.addGlobalOptions;exports.convertTableToExcel=e.convertTableToExcel;exports.excelToJson=e.excelToJson;exports.excelToNode=e.excelToNode;exports.extractExcelData=e.extractExcelData;exports.generateCSV=e.generateCSV;exports.generateExcel=e.generateExcel;exports.generateText=e.generateText;exports.replaceInExcel=e.replaceInExcel;exports.sideBySideLineByLine=e.sideBySideLineByLine;exports.themeBaseGenerate=e.themeBaseGenerate; \ No newline at end of file diff --git a/dist/excel-table.d.ts b/dist/excel-table.d.ts index d2ad689..e69de29 100644 --- a/dist/excel-table.d.ts +++ b/dist/excel-table.d.ts @@ -1,1137 +0,0 @@ -export declare const addGlobalOptionFromExcelTable: typeof addGlobalOptionFromExcelTable_2; - -/** - * Adds global options from an Excel table. - * @param {string} key - The key for the global option. - * @param {ExcelTable} data - The Excel table data. - */ -declare function addGlobalOptionFromExcelTable_2(key: string, data: ExcelTable): void; - -export declare const addGlobalOptions: typeof addGlobalOptions_2; - -/** - * Adds global options to the proxy. - * @param {string} key - The key for the global option. - * @param {string} path - The path for the global option. - * @param {any} data - The data for the global option. - */ -declare function addGlobalOptions_2(key: string, path: string, data: any): void; - -/** - * Horizontal alignment options. - * @typedef {"center" | "left" | "right"} AlignmentHorizontal - */ -declare type AlignmentHorizontal = "center" | "left" | "right"; - -/** - * Options for configuring alignment. - * @interface - */ -declare interface AlignmentOption { - horizontal?: AlignmentHorizontal; - vertical?: AlignmentVertical; - wrapText?: "0" | "1" | 0 | 1; - shrinkToFit?: "0" | "1" | 0 | 1; - readingOrder?: "1" | "2" | 2 | 1; - textRotation?: number; - indent?: number; - rtl?: boolean; - ltr?: boolean; -} - -/** - * Keys for alignment options. - * @typedef {"horizontal" | "vertical" | "wrapText" | "shrinkToFit" | "readingOrder" | "textRotation" | "indent"} AlignmentOptionKey - */ -declare type AlignmentOptionKey = "horizontal" | "vertical" | "wrapText" | "shrinkToFit" | "readingOrder" | "textRotation" | "indent"; - -/** - * Vertical alignment options. - * @typedef {"center" | "top" | "bottom"} AlignmentVertical - */ -declare type AlignmentVertical = "center" | "top" | "bottom"; - -/** - * Options for displaying the sheet as a table. - * @interface - */ -declare interface AsTableOption { - /** The type of table style. */ - type?: "Light" | "Medium" | "Dark"; - /** The style number of the table. */ - styleNumber?: number; - /** Indicates if the first column should be styled. */ - firstColumn?: boolean; - /** Indicates if the last column should be styled. */ - lastColumn?: boolean; - /** Indicates if row stripes should be applied. */ - rowStripes?: boolean; - /** Indicates if column stripes should be applied. */ - columnStripes?: boolean; -} - -/** - * Directions for border options. - * @typedef {"full" | "top" | "left" | "right" | "bottom"} BorderDirection - */ -declare type BorderDirection = "full" | "top" | "left" | "right" | "bottom"; - -/** - * Options for configuring borders. - * @interface - */ -declare type BorderOption = { - [key in BorderDirection]?: { - color: string; - style: "slantDashDot" | "dotted" | "thick" | "hair" | "dashDot" | "dashDotDot" | "dashed" | "thin" | "mediumDashDot" | "medium" | "double" | "mediumDashed"; - }; -}; - -/** - * Represents a buffer. - * @class - * @extends {Uint8Array} - */ -declare class Buffer_2 extends Uint8Array { - constructor(str: string, encoding?: string); - constructor(size: number); - constructor(array: Uint8Array); - constructor(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number); - static alloc(size: number, fill?: string | Buffer_2 | number, encoding?: string): Buffer_2; - static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer_2; - static from(data: number[]): Buffer_2; - static from(str: string, encoding?: string): Buffer_2; - write(string: string, offset?: number, length?: number, encoding?: string): number; - toString(encoding?: string, start?: number, end?: number): string; - slice(start?: number, end?: number): Buffer_2; - static concat(list: Buffer_2[], totalLength?: number): Buffer_2; - length: number; - byteOffset: number; -} - -/** - * Represents a checkbox in the sheet. - * @interface - */ -declare interface Checkbox { - col: number; - row: number; - text: string; - link?: string; - checked?: boolean; - mixed?: boolean; - threeD?: boolean; - startStr?: string; - endStr?: string; -} - -declare function checkSheetValidWithOneRef(ref: string): boolean; - -declare function checkSheetValidWithTwoRef(ref: string): boolean; - -declare type ColWidthScaleFunction = (data: number, colIndex: number) => number; - -/** - * Represents a comment in the sheet. - * @interface - */ -declare interface Comment_2 { - comment?: string; - styleId?: string; - author?: string; -} - -/** - * Function type for comment condition. - * @callback CommentConditionFunction@callback CommentConditionFunction - * @param {Header | string | number | undefined} data - The data to apply the condition to. - * @param {null | Data} object - The data object. - * @param {string} headerKey - The header key. - * @param {number} rowIndex - The row index. - * @param {number} colIndex - The column index. - * @param {boolean} fromHeader - Indicates if the condition is from the header. - * @returns {Comment | string | false | undefined | null} The comment or null. - */ -declare type CommentConditionFunction = (data: Header | string | number | undefined, object: null | Data, headerKey: string, rowIndex: number, colIndex: number, fromHeader: boolean) => Comment_2 | string | false | undefined | null; - -/** - * Represents conditional formatting in the sheet. - * @interface - * @extends {ConditionalFormattingOption} - */ -declare interface ConditionalFormatting extends ConditionalFormattingOption { - /** The start cell for the conditional formatting. */ - start: string; - /** The end cell for the conditional formatting. */ - end: string; -} - -/** - * Operations for conditional formatting cells. - * @typedef {"lt" | "gt" | "between" | "eq" | "ct"} ConditionalFormattingCellsOperation - */ -declare type ConditionalFormattingCellsOperation = "lt" | "gt" | "between" | "eq" | "ct"; - -/** - * Operations for conditional formatting icon sets. - * @typedef {"3Arrows" | "4Arrows" | "5Arrows" | "5ArrowsGray" | "4ArrowsGray" | "3ArrowsGray"} ConditionalFormattingIconSetOperation - */ -declare type ConditionalFormattingIconSetOperation = "3Arrows" | "4Arrows" | "5Arrows" | "5ArrowsGray" | "4ArrowsGray" | "3ArrowsGray"; - -/** - * Options for conditional formatting. - * @interface - */ -declare interface ConditionalFormattingOption { - /** The type of conditional formatting. */ - type: "cells" | "dataBar" | "iconSet" | "colorScale" | "top"; - /** The operator for the conditional formatting. */ - operator?: string | ConditionalFormattingCellsOperation | ConditionalFormattingIconSetOperation | ConditionalFormattingTopOperation; - /** The value for the conditional formatting. */ - value?: number | string; - /** The priority of the conditional formatting. */ - priority?: number; - /** The colors for the conditional formatting. */ - colors?: string[]; - /** Indicates if the conditional formatting is for the bottom values. */ - bottom?: boolean; - /** The style ID for the conditional formatting. */ - styleId?: string; - /** The percentage for the conditional formatting. */ - percent?: number; -} - -/** - * Operations for conditional formatting top values. - * @typedef {"belowAverage" | "aboveAverage"} ConditionalFormattingTopOperation - */ -declare type ConditionalFormattingTopOperation = "belowAverage" | "aboveAverage"; - -/** - * Converts an HTML table to an Excel file. - * @param {string} [queryForTable] - The query selector for the table. - * @param {HTMLTableElement} [table] - The HTML table element. - * @param {Object} [config] - The configuration options. - * @param {boolean} [config.keepStyle] - Whether to keep the style. - * @param {RowHeightScaleFunction} [config.rowHeightScaleFunction] - The function to scale row height. - * @param {ColWidthScaleFunction} [config.colWidthScaleFunction] - The function to scale column width. - * @returns {Promise} The generated Excel table. - */ -export declare function convertTableToExcel(queryForTable?: string, table?: HTMLTableElement, config?: { - keepStyle?: boolean; - rowHeightScaleFunction?: RowHeightScaleFunction; - colWidthScaleFunction?: ColWidthScaleFunction; -}): Promise; - -/** - * Represents a custom formula setting. - * @interface - */ -declare interface CustomFormulaSetting { - isArray?: boolean; - referenceCells?: string; - formula: string; - returnType?: string; - styleId?: string; -} - -/** - * Represents data in the sheet. - * @interface - * @extends {DataOptions} - */ -declare interface Data extends DataOptions { - [key: string]: string | number | any | undefined; -} - -declare namespace DataModel { - export { - ExcelTable, - ExcelTableOption, - Sheet, - SheetOption, - AsTableOption, - PageBreak, - ViewStart, - ViewOption, - HeaderFooterOption, - HeaderFooterLocationMap, - HeaderFooterTypes, - PageOption, - Header, - HeaderOption, - StyleType, - StyleBody, - Styles, - Data, - DataOptions, - DropDown, - RowMap, - ProtectionOption, - ProtectionOptionKey, - ConditionalFormattingCellsOperation, - ConditionalFormattingIconSetOperation, - ConditionalFormattingTopOperation, - ConditionalFormattingOption, - ConditionalFormatting, - ImageTypes, - SideBySide, - AlignmentOptionKey, - AlignmentHorizontal, - AlignmentVertical, - AlignmentOption, - BorderDirection, - BorderOption, - MapMultiStyleValue, - MultiStyleValue, - MultiStyleRexValue, - Comment_2 as Comment, - MergeRowConditionMap, - MultiStyleConditionFunction, - CommentConditionFunction, - StyleCellConditionFunction, - MergeRowDataConditionFunction, - SortAndFilter, - Title, - HeaderRowOption, - Checkbox, - NoArgFormulaType, - FormulaType, - SingleRefFormulaType, - FormatMap, - Formula, - FormulaSetting, - CustomFormulaSetting, - SingleRefFormulaSetting, - NoArgFormulaSetting, - StyleMapper, - MapComment, - ThemeOption, - ExtractedData, - ExtractResult, - ReadResult, - Buffer_2 as Buffer, - ReplacerOption, - ExcelToNodeConfig - } -} -export { DataModel } - -/** - * Options for configuring data in the sheet. - * @interface - */ -declare interface DataOptions { - [key: string]: "0" | "1" | number | string | undefined | MapComment - /** Array of multi-style values for the data. */ - | MapMultiStyleValue; - outlineLevel?: number; - hidden?: "0" | "1" | number; - rowStyle?: string; - height?: number; - multiStyleValue?: MapMultiStyleValue; - comment?: MapComment; -} - -/** - * Represents a dropdown in the sheet. - * @interface - */ -declare interface DropDown { - /** Array of options for the dropdown. */ - option: (string | number)[]; - /** Array of columns the dropdown applies to. */ - for: string[]; -} - -/** - * Represents an Excel table with options and sheets. - * @interface - * @extends {ExcelTableOption} - */ -declare interface ExcelTable extends ExcelTableOption { - /** Array of sheets in the Excel table. */ - sheet: Sheet[]; -} - -/** - * Options for configuring an Excel table. - * @interface - */ -declare interface ExcelTableOption { - /** Indicates if the Excel should not be saved. */ - notSave?: boolean; - /** The creator of the Excel. */ - creator?: string; - /** Indicates if the backend is used. */ - backend?: boolean; - /** Activates conditional formatting. */ - activateConditionalFormatting?: boolean; - /** Function to fetch data. */ - fetch?: Function; - /** The file name of the Excel. */ - fileName?: string; - /** The type of generated file. */ - generateType?: "nodebuffer" | "array" | "binarystring" | "base64"; - /** Adds default title style. */ - addDefaultTitleStyle?: boolean; - /** The creation date of the Excel. */ - created?: string; - /** The modification date of the Excel. */ - modified?: string; - /** The number of columns in the Excel. */ - numberOfColumn?: number; - /** The type of creation. */ - createType?: string; - /** Styles applied to the Excel. */ - styles?: Styles; - /** Format map for the Excel. */ - formatMap?: FormatMap; -} - -export declare function excelToJson(uri: string, fetchFunc?: Function, withHeader?: boolean, defaultPropertyPrefix?: string): Promise>; - -/** - * Converts an Excel file to a Node. - * @param {string} uri - The URI of the Excel file. - * @param {string | null} [queryForTable] - The query selector for the table. - * @param {HTMLDivElement | null} [containerElement] - The container element. - * @param {ExcelToNodeConfig} [config=defaultConfig] - The configuration options. - * @returns {Promise} The result of the conversion. - */ -export declare function excelToNode(uri: string, queryForTable?: string | null, containerElement?: HTMLDivElement | null, config?: ExcelToNodeConfig): Promise; - -/** - * Represents configuration options for Excel to Node. - * @interface - */ -declare interface ExcelToNodeConfig { - fetchFunc?: Function; - firstHeader?: boolean; - returnTableNodes?: boolean; - emptyNodeDefaultString?: string; - removeContainerChildNode?: boolean; - containerNodeStyle?: object; - tableStyle?: object; - cellStyle?: object; - buttonContainerStyle?: object; - buttonStyle?: object; - activeButtonStyle?: object; -} - -declare const exportedForTesting: { - checkSheetValidWithOneRef: typeof checkSheetValidWithOneRef; - checkSheetValidWithTwoRef: typeof checkSheetValidWithTwoRef; - generalValidationCheck: typeof generalValidationCheck; -}; - -/** - * Represents extracted data. - * @typedef {(string | null | undefined)[][]} ExtractedData - */ -declare type ExtractedData = (string | null | undefined)[][]; - -/** - * Extracts data from an Excel file. - * @param {string} uri - The URI of the Excel file. - * @param {boolean} [isBackend=false] - Whether the extraction is done on the backend. - * @param {Function} [fetchFunc] - The function to fetch data. - * @returns {Promise} The extracted data. - */ -export declare function extractExcelData(uri: string, isBackend?: boolean, fetchFunc?: Function): Promise; - -/** - * Represents the result of data extraction. - * @interface - */ -declare interface ExtractResult { - [sheetName: string]: ExtractedData; -} - -/** - * Represents a format map. - * @interface - */ -declare interface FormatMap { - [format: string]: { - key: number; - value?: string; - }; -} - -/** - * Represents a formula in the sheet. - * @interface - */ -declare interface Formula { - [insertCell: string]: FormulaSetting | SingleRefFormulaSetting | NoArgFormulaSetting | CustomFormulaSetting; -} - -/** - * Represents a formula setting. - * @interface - */ -declare interface FormulaSetting { - type: FormulaType; - start: string; - end: string; - styleId?: string; -} - -/** - * Types of formulas. - * @typedef {"AVERAGE" | "SUM" | "COUNT" | "MAX" | "MIN"} FormulaType - */ -declare type FormulaType = "AVERAGE" | "SUM" | "COUNT" | "MAX" | "MIN"; - -declare function generalValidationCheck(value: never, validateProperty: ValidationObject, property: string, strict: boolean, warn: boolean): boolean; - -/** - * Generates a CSV file from an Excel table Object. - * @param {ExcelTable} excelTable - The Excel table. - * @param {boolean} [asZip=false] - Whether to generate the CSV as a ZIP file. - * @returns {Promise} The generated CSV file. - */ -export declare function generateCSV(excelTable: ExcelTable, asZip?: boolean): Promise; - -export declare function generateExcel(data: ExcelTable, styleKey?: string): Promise; - -/** - * Generates a text file from an Excel table Object. - * @param {ExcelTable} excelTable - The Excel table. - * @param {boolean} [asZip=false] - Whether to generate the text file as a ZIP file. - * @returns {Promise} The generated text file. - */ -export declare function generateText(excelTable: ExcelTable, asZip?: boolean): Promise; - -/** - * Represents a header in the sheet. - * @interface - * @extends {HeaderOption} - */ -declare interface Header extends HeaderOption { - /** The label of the header. */ - label: string; - /** The text of the header. */ - text: string; -} - -/** - * Location map for header and footer options.l:Left, c:Center, r:Right - * @interface - */ -declare interface HeaderFooterLocationMap { - l?: HeaderFooterOption; - c?: HeaderFooterOption; - r?: HeaderFooterOption; -} - -/** - * Options for header and footer. - * @interface - */ -declare interface HeaderFooterOption { - /** The text of the header or footer. */ - text?: string; - /** The style ID of the header or footer. */ - styleId?: string; -} - -/** - * Types of header and footer in page(odd page, even page,first page). - * @interface - */ -declare interface HeaderFooterTypes { - odd?: HeaderFooterLocationMap; - even?: HeaderFooterLocationMap; - first?: HeaderFooterLocationMap; -} - -/** - * Options for configuring a header. - * @interface - */ -declare interface HeaderOption { - /** The size(width) of the header. */ - size?: number; - /** Array of multi-style values for the header. */ - multiStyleValue?: MultiStyleValue[]; - /** Comment for the header. */ - comment?: Comment_2 | string; - /** Conditional formatting options for the header. */ - conditionalFormatting?: ConditionalFormattingOption; - /** Formula applied to the column. */ - formula?: { - /** The type of the formula. */ - type: FormulaType; - /** The style ID of the formula. */ - styleId?: string; - }; -} - -/** - * Options for the header row. - * @interface - */ -declare interface HeaderRowOption { - outlineLevel: "string"; -} - -/** - * Represents an image in the sheet. - * @interface - */ -declare interface ImageTypes { - url: string; - from: string; - to?: string; - type?: "one" | "two"; - extent?: { - cx: number; - cy: number; - }; - margin?: { - all?: number; - right?: number; - left?: number; - bottom?: number; - top?: number; - }; -} - -/** - * Represents a map of comments. - * @interface - */ -declare interface MapComment { - [key: string]: Comment_2 | string; -} - -/** - * Represents a map of multi-style values. - * @interface - */ -declare interface MapMultiStyleValue { - [key: string]: MultiStyleValue[]; -} - -/** - * Represents a map of merge row conditions. - * @interface - */ -declare interface MergeRowConditionMap { - [columnKey: string]: { - inProgress: boolean; - start: number; - }; -} - -/** - * Function type for merge row data condition. - * @callback MergeRowDataConditionFunction@callback MergeRowDataConditionFunction - * @param {Header | string | number | undefined} data - The data to apply the condition to. - * @param {string | null} key - The key. - * @param {number} index - The index. - * @param {boolean} fromHeader - Indicates if the condition is from the header. - * @returns {boolean} The result of the condition. - */ -declare type MergeRowDataConditionFunction = (data: Header | string | number | undefined, key: string | null, index: number, fromHeader: boolean) => boolean; - -/** - * Function type for multi-style condition. - * @callback MultiStyleConditionFunction@callback MultiStyleConditionFunction - * @param {Header | string | number | undefined} data - The data to apply the condition to. - * @param {null | Data} object - The data object. - * @param {string} headerKey - The header key. - * @param {number} rowIndex - The row index. - * @param {number} colIndex - The column index. - * @param {boolean} fromHeader - Indicates if the condition is from the header. - * @returns {MultiStyleValue[] | null} The multi-style values or null. - */ -declare type MultiStyleConditionFunction = (data: Header | string | number | undefined, object: null | Data, headerKey: string, rowIndex: number, colIndex: number, fromHeader: boolean) => MultiStyleValue[] | null; - -/** - * Represents a multi-style regex value. - * @interface - */ -declare interface MultiStyleRexValue { - reg: RegExp | string; - styleId: string; -} - -/** - * Represents a multi-style value. - * @interface - */ -declare interface MultiStyleValue { - value: string | number; - styleId?: string; -} - -/** - * Represents a no-argument formula setting. - * @interface - */ -declare interface NoArgFormulaSetting { - noArgType: NoArgFormulaType; - styleId?: string; -} - -/** - * Types of no-argument formulas. - * @typedef {"NOW" | "TODAY" | "HOUR" | "NOW_YEAR" | "NOW_HOUR" | "NOW_SECOND" | "NOW_MIN" | "NOW_MONTH" | "NOW_DAY" | "NOW_WEEKDAY" | "NOW_MINUTE"} NoArgFormulaType - */ -declare type NoArgFormulaType = "NOW" | "TODAY" | "HOUR" | "NOW_YEAR" | "NOW_HOUR" | "NOW_SECOND" | "NOW_MIN" | "NOW_MONTH" | "NOW_DAY" | "NOW_WEEKDAY" | "NOW_MINUTE"; - -/** - * Options for page breaks in the sheet. - * @interface - */ -declare interface PageBreak { - /** Array of row indices where page breaks should occur. */ - row?: number[]; - /** Array of column indices where page breaks should occur. */ - column?: number[]; -} - -/** - * Options for configuring the page. - * @interface - */ -declare interface PageOption { - /** Margin settings for the page. */ - margin?: { - left?: number; - right?: number; - top?: number; - bottom?: number; - header?: number; - footer?: number; - }; - /** Header settings for the page. */ - header?: HeaderFooterTypes; - /** Footer settings for the page. */ - footer?: HeaderFooterTypes; - /** Indicates if the page is in portrait orientation. */ - isPortrait: boolean; -} - -/** - * Represents protection options for the sheet. - * @typedef {Object} ProtectionOption@typedef {Object} ProtectionOption - * @property {"0" | "1" | 0 | 1} sheet - Protect the sheet. - * @property {"0" | "1" | 0 | 1} formatCells - Allow formatting cells. - * @property {"0" | "1" | 0 | 1} formatColumns - Allow formatting columns. - * @property {"0" | "1" | 0 | 1} formatRows - Allow formatting rows. - * @property {"0" | "1" | 0 | 1} insertColumns - Allow inserting columns. - * @property {"0" | "1" | 0 | 1} insertRows - Allow inserting rows. - * @property {"0" | "1" | 0 | 1} insertHyperlinks - Allow inserting hyperlinks. - * @property {"0" | "1" | 0 | 1} deleteColumns - Allow deleting columns. - * @property {"0" | "1" | 0 | 1} deleteRows - Allow deleting rows. - * @property {"0" | "1" | 0 | 1} sort - Allow sorting. - * @property {"0" | "1" | 0 | 1} autoFilter - Allow using auto filter. - * @property {"0" | "1" | 0 | 1} pivotTables - Allow using pivot tables. - */ -declare type ProtectionOption = { - [key in ProtectionOptionKey]: "0" | "1" | 0 | 1; -}; - -/** - * Keys for protection options. - * @typedef {"sheet" | "formatCells" | "formatColumns" | "formatRows" | "insertColumns" | "insertRows" | "insertHyperlinks" | "deleteColumns" | "deleteRows" | "sort" | "autoFilter" | "pivotTables"} ProtectionOptionKey - */ -declare type ProtectionOptionKey = "sheet" | "formatCells" | "formatColumns" | "formatRows" | "insertColumns" | "insertRows" | "insertHyperlinks" | "deleteColumns" | "deleteRows" | "sort" | "autoFilter" | "pivotTables"; - -/** - * Represents the result of reading data. - * @interface - */ -declare interface ReadResult { - data: ExtractResult; - sheetNameObject: Record; - sheetName: IterableIterator<[string, string]>; - maxLengthOfColumn: Record; -} - -export declare function replaceInExcel(url: string | null | undefined, replaceData: Record, option?: ReplacerOption): Promise; - -/** - * Represents options for the replacer. - * @interface - */ -declare interface ReplacerOption { - fileName?: string; - backend?: boolean; - fetch?: Function; - data?: Blob | Buffer_2; - notSave?: boolean; - generateType?: "nodebuffer" | "array" | "binarystring" | "base64"; -} - -declare type RowHeightScaleFunction = (data: number, rowIndex: number, fromHeader: boolean) => number; - -/** - * Represents a map of rows in the sheet. - * @interface - */ -declare interface RowMap { - [rowNumber: number]: { - startTag: string; - endTag: string; - details: string; - }; -} - -/** - * Represents a sheet in the Excel. - * @interface - * @extends {SheetOption} - */ -declare interface Sheet extends SheetOption { - /** Array of headers in the sheet. */ - headers: Header[]; - /** Array of data in the sheet. */ - data: Data[]; -} - -/** - * Options for configuring a sheet. - * @interface - */ -declare interface SheetOption { - /** Indicates if the sheet should be without a header. */ - withoutHeader?: boolean; - /** Options for configure property name that maybe provide for apply outlineLevel, hidden, height option of row*/ - mapSheetDataOption?: { - /** Outline level of the sheet data. */ - outlineLevel?: string; - /** Indicates if the sheet data is hidden. */ - hidden?: string; - /** Height of the sheet data. */ - height?: string; - }; - /** Background image of the sheet. */ - backgroundImage?: string; - /** Array of conditional formatting rules. */ - conditionalFormatting?: ConditionalFormatting[]; - /** Function for multi-style condition. */ - multiStyleCondition?: MultiStyleConditionFunction; - /** Indicates if the sheet should use split based on match. */ - useSplitBaseOnMatch?: boolean; - /** Indicates if strings should be converted to numbers Automatically. */ - convertStringToNumber?: boolean; - /** Array of images in the sheet. */ - images?: ImageTypes[]; - /** Formula applied to the sheet. */ - formula?: Formula; - /** Page options for the sheet. */ - pageOption?: PageOption; - /** Name of the sheet. */ - name?: string; - /** Title of the sheet. */ - title?: Title; - /** Shift sheet from top. */ - shiftTop?: number; - /** Shift sheet from Left. */ - shiftLeft?: number; - /** Indicates if the sheet is selected. */ - selected?: boolean; - /** Tab color of the sheet. */ - tabColor?: string; - /** Array of merge ranges in the sheet. */ - merges?: string[]; - /** Key for the header style. */ - headerStyleKey?: string; - /** Function for merge row data base on condition. */ - mergeRowDataCondition?: MergeRowDataConditionFunction; - /** Function for style cell base on condition. */ - styleCellCondition?: StyleCellConditionFunction; - /** Function for comment base on condition. */ - commentCondition?: CommentConditionFunction; - /** Sort and filter options for the sheet. */ - sortAndFilter?: SortAndFilter; - /** State of the sheet (hidden or visible). */ - state?: "hidden" | "visible"; - /** Options for the header row. */ - headerRowOption?: object; - /** Protection options for the sheet. */ - protectionOption?: ProtectionOption; - /** Height of the header. */ - headerHeight?: number; - /** Array of checkboxes in the sheet. */ - checkbox?: Checkbox[]; - /** View options for the sheet. */ - viewOption?: ViewOption; - /** Indicates if the sheet is right-to-left. */ - rtl?: boolean; - /** Page break options for the sheet. */ - pageBreak?: PageBreak; - /** Options for displaying the sheet as a table. */ - asTable?: AsTableOption; - /** Array of dropdowns in the sheet. */ - dropDowns?: DropDown[]; -} - -/** - * Represents side-by-side data in the sheet. - * @interface - */ -declare interface SideBySide { - sheetName?: string; - spaceX?: number; - spaceY?: number; - headers: { - label: string; - text: string; - }[]; - data: Data[]; - headerIndex?: number; -} - -/** - * Generates an Excel file with side-by-side data. - * @param {SideBySide[][]} data - The side-by-side data. - * @returns {Promise} The generated Excel table. - */ -export declare function sideBySideLineByLine(data: SideBySide[][]): Promise; - -/** - * Represents a single-reference formula setting. - * @interface - */ -declare interface SingleRefFormulaSetting { - type: SingleRefFormulaType; - referenceCell: string; - value?: number | string; - styleId?: string; -} - -/** - * Types of single-reference formulas. - * @typedef {"LEN" | "MODE" | "UPPER" | "LOWER" | "PROPER" | "RIGHT" | "LEFT" | "ABS" | "POWER" | "MOD" | "FLOOR" | "CEILING" | "ROUND" | "SQRT" | "COS" | "SIN" | "TAN" | "COT" | "COUNTIF" | "SUMIF" | "TRIM"} SingleRefFormulaType - */ -declare type SingleRefFormulaType = "LEN" | "MODE" | "UPPER" | "LOWER" | "PROPER" | "RIGHT" | "LEFT" | "ABS" | "POWER" | "MOD" | "FLOOR" | "CEILING" | "ROUND" | "SQRT" | "COS" | "SIN" | "TAN" | "COT" | "COUNTIF" | "SUMIF" | "TRIM"; - -/** - * Represents sort and filter options. - * @interface - */ -declare interface SortAndFilter { - mode: "all" | "ref"; - ref?: string; -} - -/** - * Represents the body of a style. - * @interface - */ -declare interface StyleBody { - /** The font family of the text. */ - fontFamily?: string; - /** The type of the style.(if not define used for cells, for other type should be define) */ - type?: StyleType; - /** The size of the font. */ - size?: number; - /** The index of the style(!!it's will override by process,Don't set value for it). */ - index?: number; - /** The alignment options of the text. */ - alignment?: AlignmentOption; - /** The border options. */ - border?: BorderOption; - /** The format of the text. */ - format?: string; - /** Indicates if the style is bold. */ - bold?: boolean; - /** Indicates if the style is underlined. */ - underline?: boolean; - /** Indicates if the style is italic. */ - italic?: boolean; - /** Indicates if the style has double underline. */ - doubleUnderline?: boolean; - /** The color of the style. */ - color?: string; - /** The background color of the style. */ - backgroundColor?: string; -} - -/** - * Function type for style cell condition. - * @callback StyleCellConditionFunction@callback StyleCellConditionFunction - * @param {Header | string | number | undefined} data - The data to apply the condition to. - * @param {Header | Data} object - The data object. - * @param {number} rowIndex - The row index. - * @param {number} colIndex - The column index. - * @param {boolean} fromHeader - Indicates if the condition is from the header. - * @param {string[]} styleKeys - The style keys. - * @returns {string | null} The style key or null. - */ -declare type StyleCellConditionFunction = (data: Header | string | number | undefined, object: Header | Data, rowIndex: number, colIndex: number, fromHeader: boolean, styleKeys: string[]) => string | null; - -/** - * Represents a style mapper. - * @interface - */ -declare interface StyleMapper { - conditionalFormatting: { - count: number; - value: string; - }; - commentSyntax: { - value: { - [key: string]: string; - }; - }; - format: { - count: number; - value: string; - }; - border: { - count: number; - value: string; - }; - fill: { - count: number; - value: string; - }; - font: { - count: number; - value: string; - }; - cell: { - count: number; - value: string; - }; -} - -/** - * Represents a collection of styles. - * @interface - */ -declare interface Styles { - [key: string]: StyleBody; -} - -/** - * Types of styles that can be applied(not value for cell, CF/conditionalFormatting for conditionalFormatting option and HF/headerFooter for headerFooter option). - * @typedef {"conditionalFormatting" | "CF" | "headerFooter" | "HF"} StyleType - */ -declare type StyleType = "conditionalFormatting" | "CF" | "headerFooter" | "HF"; - -/** - * Generates an Excel file with a theme. - * @param {ExcelTable | Data[] | Data[][]} data - The data for the Excel file. - * @param {ThemeOption} [option] - The theme options. - * @returns {Promise} The generated Excel table. - */ -export declare function themeBaseGenerate(data: ExcelTable | Data[] | Data[][], option?: ThemeOption): Promise; - -/** - * Represents theme options. - * @interface - */ -declare interface ThemeOption { - negativeColor?: boolean; - headerColor?: string; - rowColor?: string; - headerBackgroundColor?: string; - rowBackgroundColor?: string; - fileName?: string; - filterKeys?: string[]; -} - -/** - * Represents the title of the sheet. - * @interface - */ -declare interface Title { - shiftTop?: number; - shiftLeft?: number; - consommeRow?: number; - consommeCol?: number; - height?: number; - styleId?: string; - text?: string; - multiStyleValue?: MultiStyleValue[]; - comment?: Comment_2 | string; -} - -declare function validateExcelTableObjectFunction(data: ExcelTable, strict?: boolean, warn?: boolean): void; - -declare function validateSheetArrayFunction(sheets: Sheet[] | Sheet, strict?: boolean, warn?: boolean): void; - -declare function validateStyleObjectFunction(styles: Styles, strict?: boolean, warn?: boolean): void; - -declare interface ValidationObject { - mode: ValidationType; - type: string; - isEnum?: boolean; - enum?: string[]; - isArray?: boolean; - notEmpty?: boolean; - min?: number; - validateFunction?: (key: string, value: any, strict: boolean, warn: boolean) => boolean; -} - -declare type ValidationType = "TYPE_CHECK"; - -declare namespace Validator { - export { - validateStyleObjectFunction, - validateSheetArrayFunction, - validateExcelTableObjectFunction, - exportedForTesting - } -} -export { Validator } - -/** - * Options for configuring the view of the sheet. - * @interface - */ -declare interface ViewOption { - /** The type of view. */ - type?: "pageLayout" | "pageBreakPreview"; - /** Indicates if the grid should be hidden. */ - hideGrid?: boolean; - /** Indicates if the headlines should be hidden. */ - hideHeadlines?: boolean; - /** Indicates if the ruler should be hidden. */ - hideRuler?: boolean; - /** Options for freezing rows or columns. */ - frozenOption?: { - /** The type of freezing. */ - type: "ROW" | "COLUMN" | "BOTH" | "R" | "C" | "B"; - /** The index/position at which to freeze. */ - index: number | { - r: number; - c: number; - }; - }; - /** Options for splitting the view. */ - splitOption?: { - /** The type of split. */ - type: "VERTICAL" | "HORIZONTAL" | "BOTH" | "V" | "H" | "B"; - /** The start position of the split. */ - startAt?: ViewStart; - /** The position of the split. */ - split: number | { - x: number; - y: number; - }; - }; -} - -/** - * Options for the start of the view. - * @interface - */ -declare interface ViewStart { - t?: string; - b?: string; - r?: string; - l?: string; - one?: string; - two?: string; -} - -export { } diff --git a/dist/excel-table.iife.js b/dist/excel-table.iife.js index 706dcd2..8b13789 100644 --- a/dist/excel-table.iife.js +++ b/dist/excel-table.iife.js @@ -1,55 +1 @@ -var ExcelTable=function(Ie){"use strict";function kt(h,w){for(var o=0;ob[c]})}}}return Object.freeze(Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}))}function St(h){return h.replace(/ /g,"")}function Et(h){if(h=h.replace(/^#/,""),h.length==3){const w=h.charAt(0),o=h.charAt(1),b=h.charAt(2);return w+w+o+o+b+b}else return h}function rr(h){/^#?([a-f\d]{3})$/i.test(h)&&(h=Et(h));var w=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(h);return w?[parseInt(w[1],16),parseInt(w[2],16),parseInt(w[3],16)]:[0,0,0]}function Tt(h){const w=rr(h);return w==null?void 0:(.299*w[0]+.587*w[1]+.114*w[2])/255>.5?"rgb(0,0,0)":"rgb(255,255,255)"}function At(h){/^#?([a-f\d]{3})$/i.test(h)&&(h=Et(h));var w=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(h);return w?"rgb("+(255-parseInt(w[1],16))+","+(255-parseInt(w[2],16))+","+(255-parseInt(w[3],16))+")":"rgb(0,0,0)"}function ft(h){h=Number(h);var w=h.toString(16);return w.length==1?"0"+w:w}function je(h){h=St(h);let w=h.indexOf("rgba")>=0?h.substring(5,h.length-1).split(","):h.substring(4,h.length-1).split(","),o=w.reduce((b,c)=>b&&!Number.isNaN(Number(c)),!0);return w.length==4&&w[3]=="0"||w.length!=3&&w.length!=4||!o?null:(ft(w[0])+ft(w[1])+ft(w[2])).toUpperCase()}function Ue(h,w){if(typeof h>"u"||h===null)return null;if(!w){let o=St(h);o.indexOf("var(")==0&&o.lastIndexOf(")")==o.length-1&&(o=o.substring(4,o.length-1),h=getComputedStyle(document.documentElement).getPropertyValue(o))}if(h.indexOf("rgb")>=0){const o=je(h);h=o||""}return h.replace(/^#/,"")}function nr(h){let w="";return h.indexOf("_")>0?h.replace(/[a-z]/g,"").length==h.length?w=h.split(/_/).reduce((o,b)=>o+b.charAt(0)+b.substring(1).toLowerCase()+" ","").trim():w=h.replace(/_/g," ").trim():(w=h.replace(/([A-Z])/g," $1").trim(),w=w.charAt(0).toUpperCase()+w.substring(1).trim()),w}function Ot(h,w){let o=Object.keys(h).filter(r=>!w.includes(r)),b=[];return o.reduce((r,f)=>(r.push({label:f,text:nr(f)}),r),b)}const ct={fileName:"MR-Excel",headerBackgroundColor:"#393E46",headerColor:"#EEEEEE",negativeColor:!1,rowBackgroundColor:"#EEEEEE",rowColor:"#393E46",filterKeys:[]},ir=function(h,w={...ct}){let o;if(typeof h=="object"&&Array.isArray(h))if(h.length>0)if(Array.isArray(h[0])){let l=[];for(let s=0;s0){const _=Ot(u[0],Array.isArray(w.filterKeys)?w.filterKeys:[]);l.push({headers:_,data:u})}}o={sheet:l}}else h.length>0?o={sheet:[{headers:Ot(h[0],Array.isArray(w.filterKeys)?w.filterKeys:[]),data:h}]}:o={sheet:[]};else o={sheet:[]};else o=h;let b=w&&w.headerBackgroundColor?w.headerBackgroundColor:ct.headerBackgroundColor,c=w&&w.rowBackgroundColor?w.rowBackgroundColor:ct.rowBackgroundColor,r=w&&w.negativeColor?At(b):w&&w.headerColor?w.headerColor:Tt(b),f=w&&w.negativeColor?At(c):w&&w.rowColor?w.rowColor:Tt(c);typeof o.styles>"u"&&(o.styles={}),o.styles.themeStyleHeader={backgroundColor:b,color:r},o.styles.themeStyleBody={backgroundColor:c,color:f};const i=o.sheet.length;for(let l=0;lot)).default;let f;if(typeof h=="string"&&h.length){let l,s=!1;typeof(o==null?void 0:o.fetch)=="function"?(l=o==null?void 0:o.fetch,s=!0):l=fetch,f=await l(h).then(u=>{if(u==null||u==null)throw"response is null";return s?u:o!=null&&o.backend?u.arrayBuffer():u.blob()})}else f=o==null?void 0:o.data;let i=await r.loadAsync(f).then(async function(l){let s=Object.keys(l.files).filter(u=>u.indexOf("xl/worksheets/")==0&&u.length-4==u.lastIndexOf(".xml")||u=="xl/sharedStrings.xml");for(let u=0;u{let a=v;Object.keys(w).forEach(g=>{var t;a=a.replace(new RegExp("{{"+g+"}}","g"),(t=w[g])==null?void 0:t.toString())}),b[_]=a})}return l});if(Object.keys(b).forEach(l=>{i.file(l,b[l])}),o!=null&&o.backend)return i.generateAsync({type:o.generateType?o.generateType:"nodebuffer"}).then(l=>l);if(o!=null&&o.notSave)return i.generateAsync({type:"blob"}).then(l=>l.slice(0,l.size,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));{let l=await i.generateAsync({type:"blob"});(await Promise.resolve().then(()=>bt)).saveAs(l,(o!=null&&o.fileName?o==null?void 0:o.fileName:"tableRecord")+".xlsx")}}function ar(h,w,o,b,c,r,f,i){let l=[],s="both",u=[];!w||w===0?(w=1,s="col"):u.push(w-1),!h||h===0?(h=0,s="row"):u.push(h-1);let _=c||{};_.mergeType=i&&i.mergeType?[...i.mergeType,s]:[s],_.mergeValue=i&&i.mergeValue?[...i.mergeValue,u]:[u],_.mergeStart=i&&i.mergeStart?[...i.mergeStart,o]:[o];for(let v=0;v=1?(_["c"+g]=r,r="",f+="*",a--):w>=2&&o==g?(_["c"+g]=r,r="",f+="+"):f+="-":v>0&&(f+="-");l.push({..._,mergeString:f}),_={},f=""}return l}function sr(h,w,o,b,c){var _;if(!h&&!w)throw"Error: One of the function inputs is required.";let r;h?r=(_=document.querySelector(h))==null?void 0:_.querySelectorAll("tr"):r=w==null?void 0:w.querySelectorAll("tr");let f=[],i=[],l={header:{},rows:[]},s=40;if(r){let v=!1,a=0;r.forEach((g,t)=>{var y=[].slice.call(g.children);const m=window.getComputedStyle(g,null);let x=je(m.backgroundColor);if(!v)a=y.length,v=!0,typeof b=="function"?s=b(Number(m.height.substring(0,m.height.length-2)),t,!0):s=Number(m.height.substring(0,m.height.length-2)),y.forEach((S,I)=>{let E=window.getComputedStyle(S,null),R=null;if(E.borderBottomWidth!=="0px"){const j=je(E.borderBottomColor);j&&(R||(R={}),R.bottom={style:"thin",color:j})}if(E.borderTopWidth!=="0px"){const j=je(E.borderTopColor);j&&(R||(R={}),R.top={style:"thin",color:j})}if(E.borderLeftWidth!=="0px"){const j=je(E.borderLeftColor);j&&(R||(R={}),R.left={style:"thin",color:j})}if(E.borderRightWidth!=="0px"){const j=je(E.borderRightColor);j&&(R||(R={}),R.right={style:"thin",color:j})}let D=je(E.backgroundColor);!D&&x&&(D=x);const U=parseInt(E.fontSize.substring(0,E.fontSize.indexOf("p")));let F={...D?{backgroundColor:D}:{},bold:parseInt(E.fontWeight)>500,...isNaN(U)?{}:{size:U},...R?{border:R}:{},alignment:{...typeof E.textAlign=="string"&&E.textAlign.length>0?{horizontal:E.textAlign}:{},vertical:"center",...E.direction=="rtl"?{rtl:!0}:{ltr:!0}}};l.header[t+"-"+I]=F;let L;typeof c=="function"?L=c(Number(E.width.substring(0,E.width.length-2)),I):L=Number(E.width.substring(0,E.width.length-2))*.15;const V=S.getAttribute("colspan"),k=S.getAttribute("rowspan");f.push({label:"c"+I,...V?{colspan:V}:{},...k?{rowspan:k}:{},text:S.textContent,...isNaN(L)||L<=0?{}:{size:L}})});else{let S={},I="",E=!1;i.length>=t&&(S=i[t-1],I="mergeString"in S?S.mergeString:"",E=!0);let R=0;y.forEach((D,U)=>{if("c"+(U+R)in S)for(let n=0;n<=a+1&&"c"+(U+n)in S;n++)R++;U+=R;let F=window.getComputedStyle(D,null);if(D.getAttribute("colspan")||D.getAttribute("rowspan")){let n=ar(D.getAttribute("colspan")*1,D.getAttribute("rowspan")*1,U,a,S,D.textContent,I,S);i.length{i.length500,...isNaN(k)?{}:{size:k},...L?{border:L}:{},alignment:{...typeof F.textAlign=="string"&&F.textAlign.length>0?{horizontal:F.textAlign}:{},vertical:"center",...F.direction=="rtl"?{rtl:!0}:{ltr:!0}}};l.header[t+"-"+U]=j,S["c"+U]=D.textContent}),typeof b=="function"?S.height=b(Number(m.height.substring(0,m.height.length-2)),t,!1):S.height=m.height.substring(0,m.height.length-2),typeof S.height=="string"&&S.height.length==0&&delete S.height,i.length -`+(h.format.count>0?''+h.format.value+"":"")+''+h.font.value+''+h.fill.value+''+h.border.value+''+h.cell.value+' '+(w?''+h.conditionalFormatting.value+"":'')+""}function fr(h,w,o,b,c,r,f){let i={};return` -`+o.reduce((l,s)=>(s=s.toLowerCase(),i[s]?l:s=="svg"?(i.png=!0,i.svg=!0,l+''):s=="jpeg"||s=="jpg"?(i.jpeg=!0,i.jpg=!0,l+''):(i[s]=!0,l+'')),"")+w.reduce((l,s)=>l+'',"")+h+(f.length>0?f.reduce((l,s)=>l+'',""):"")+''+(r?'':"")+''+b.reduce((l,s)=>l+'',"")+(c.length>0?c.reduce((l,s,u)=>l+'',""):"")+''}function cr(h,w){return` -Microsoft Excel0falseWorksheets`+h+' '+w+"falsefalsefalse16.0300"}function ht(h,w,o,b){h=h.toUpperCase();let c="";if(w.formula){let s=w,u=s.formula.indexOf("=")==0?s.formula.substring(1):s.formula,_=h.indexOf(":")>0,v=s.referenceCells?s.referenceCells:h,a=_?h.substring(0,h.indexOf(":")):h,g=a.replace(/[0-9]/g,""),t=parseInt(h.substr(g.length)),y=s.returnType?s.returnType:s.isArray||_?' t="str"':"",m="styleId"in s&&b&&typeof s.styleId=="string"&&b[s.styleId]?' s="'+b[s.styleId].index+'"':"",x=s.isArray||_?' t="array" ref="'+v+'"':"";return c='"+u+"",{column:g,row:t,needCalcChain:!1,isCustom:!0,cell:c}}let r=h.replace(/[0-9]/g,""),f=parseInt(h.substr(r.length)),i=!1,l="";if(w.noArgType){const s=w;if(s.noArgType=="NOW"||s.noArgType=="TODAY"){const u="styleId"in s&&b&&typeof s.styleId=="string"&&b[s.styleId]?' s="'+b[s.styleId].index+'"':"";c='"+s.noArgType+"()"}else{let u="NOW()";const _="styleId"in s&&b&&typeof s.styleId=="string"&&b[s.styleId]?' s="'+b[s.styleId].index+'"':"";c='"+s.noArgType.substring(4)+"("+u+")"}l='',i=!0}else if(w.referenceCell){const s=w;let u="";typeof s.value<"u"&&(u=","+s.value);let _="";s.type=="COT"&&(_="_xlfn.");const v="styleId"in s&&b&&typeof s.styleId=="string"&&b[s.styleId]?' s="'+b[s.styleId].index+'"':"";c='"+_+s.type+"("+s.referenceCell.toUpperCase()+u+")",l='',i=!0}else{const s=w;c='"+s.type+"("+s.start.toUpperCase()+":"+s.end.toUpperCase()+")"}return{column:r,row:f,cell:c,needCalcChain:i,chainCell:l}}function dt(h,w,o){let b=!1,c,r;if(typeof h=="object"){if("author"in h&&h.author&&(b=!0,r=h.author),"styleId"in h&&typeof h.styleId=="string"){let f=w[h.styleId];typeof f=="string"&&(o=f)}c="comment"in h&&typeof h.comment=="string"?It(h.comment):[""]}else c=h?It(h):[""];return b&&c.unshift(r+":"),{hasAuthor:b,author:r,commentStyle:o,commentStr:c}}function It(h){var w=h.split(/\r?\n|\r|\n/g);return w}function ut(h,w,o,b){let c='',r="";return w.forEach((f,i)=>{let l="";if(f.length==0){r+=` -`;return}i>0&&(l=' xml:space="preserve"',r+=` -`),c+=""+o+""+r+f+"",r=""}),r.length>0&&c.indexOf("")>0&&(c=c.substring(0,c.length-8)+r+""),c+="",c}const hr='',tt=function(h){return h.replace(/\&/g,"&").replace(/\/g,">")};function mt(h,w,o){let b="";return h.forEach(c=>{typeof c.value=="string"&&(c.value=tt(c.value)),b+=""+(c.styleId&&w[c.styleId]?w[c.styleId]:w[o])+''+c.value+""}),""+b+""}const Ft={time:{key:165,value:''},date:{key:187,value:''},short_date:{key:14},fraction:{key:13},percentage:{key:9},float_1:{key:180,value:''},float_2:{key:181,value:''},float_3:{key:164,value:''},float_4:{key:182,value:''},dollar_rounded:{key:183,value:''},dollar_2:{key:183,value:''},num_sep:{key:184,value:''},num_sep_1:{key:185,value:''},num_sep_2:{key:186,value:''},dollar:{key:163,value:''},$:{key:163,value:''},pound:{key:162,value:''},"£":{key:162,value:''},euro:{key:161,value:''},"€":{key:161,value:''},yen:{key:160,value:''},"¥":{key:160,value:''},CHF:{key:179,value:''},ruble:{key:178,value:''},"₽":{key:178,value:''},"֏":{key:177,value:''},manat:{key:176,value:''},"₼":{key:176,value:''},"₼1":{key:175,value:''},"₽1":{key:174,value:''},"₽2":{key:173,value:''},"₽3":{key:172,value:''},ريال:{key:171,value:''}},zt=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Rt=(h,w,o=!1,b)=>{let c,r=!1;return typeof b=="function"?(c=b,r=!0):c=fetch,c(h).then(f=>r?f:o?f.arrayBuffer():f.blob()).then(f=>r||o?f:new File([f],w)).catch(f=>{throw f})};function qe(h,w){h=h.toUpperCase();let o=h.replace(/[0-9]/g,"");if(o.length==0)throw"Invalid Column";let b=parseInt(h.substring(o.length));if(isNaN(b))throw"Invalid Row";b=Math.max(0,b-1);let c=w.indexOf(o);return c<0&&(w=et(w,Math.pow(10,o.length+1),""),c=w.indexOf(o),c<0&&(c=0)),{col:c,row:b}}let dr={},pt=new Proxy(dr,{get(h,w){return w in h?h[w]:(this.set(h,w,{},!0),{})},set(h,w,o,b){return h[w]=o,!0}});function Pt(h,w,o){pt[h],pt[h][w]=o}function Bt(h,w,o){Object.keys(o).forEach(c=>{const r=o[c];typeof r=="object"?c!="data"&&c!="headers"&&Bt(h,w.length>0?w+"."+c:c,r):Pt(h,w.length>0?w+"."+c:c,r)})}function ur(h,w){Bt(h,"",w)}function mr(h,w){let o=w,b=pt[h];return Object.keys(b).forEach(r=>{const f=r.split(".");let i=o,l=b[r];for(let s=0;si+" "+l,""),f=c.option.join(",");o+='"'+f+"""}return o+="",o}async function rt(h,w=""){if(typeof w=="string"&&w.length>0&&(h=mr(w,h)),typeof h.creator=="string"&&h.creator.trim().length<=0)throw'length of "creator" most be bigger then 0';if(typeof h.created=="string"&&new Date(h.created).toString()=="Invalid Date")throw'"created" is not valid date';if(typeof h.modified=="string"&&new Date(h.modified).toString()=="Invalid Date")throw'"modified" is not valid date';let o=Ft;h.formatMap&&typeof h.formatMap=="object"&&(o={...o,...h.formatMap});const b=h.backend,c={lt:"lessThan",gt:"greaterThan",between:"between",ct:"containsText",eq:"equal"};let r=[...zt];h.numberOfColumn&&h.numberOfColumn>25&&(r=et(r,h.numberOfColumn));const i=(await Promise.resolve().then(()=>ot)).default;let l=new i;h.sheet||(h.sheet=[{headers:[],data:[]}]);const s=h.sheet.length;let u=l.folder("xl"),_=null,v=null,a=null;h.styles||(h.styles={}),h.addDefaultTitleStyle&&(h.styles.titleStyle={alignment:{horizontal:"center",vertical:"center"}});const g=Object.keys(h.styles),t=hr,y=h.activateConditionalFormatting?h.activateConditionalFormatting:!1,m={},x={};let S=g.reduce((e,C,A)=>{const d=h.styles[C];if(d.type&&(d.type=="headerFooter"||d.type=="HF")){let T="",K="-",J="Regular";if(d.fontFamily&&(K=d.fontFamily),d.bold&&(J="Bold"),d.italic&&(J=="Regular"&&(J=""),J+="Italic"),(K!="-"||J!="Regular")&&(T='&"'+K+","+J+'"'),d.size&&(T+="&"+d.size),d.doubleUnderline?T+="&E":d.underline&&(T+="&U"),d.color){const q=Ue(d.color,b);typeof q=="string"&&q.length>0&&(T+="&K"+q.toUpperCase())}return m[C]=T,e}if(y&&typeof d.type=="string"&&d.type&&(d.type=="conditionalFormatting"||d.type.toUpperCase()=="CF")){x[C]=e.conditionalFormatting.count;let T=Ue(d.color,b),K=Ue(d.backgroundColor,b);return e.conditionalFormatting.value+=' ',e.conditionalFormatting.count++,e}const p={fillIndex:0,fontIndex:0,borderIndex:0,formatIndex:0};if(d.backgroundColor){let T=Ue(d.backgroundColor,b);p.fillIndex=e.fill.count,e.fill.count++,e.fill.value=e.fill.value+''+(T?'':"")+""}if(d.color||d.fontFamily||d.size||d.bold||d.italic||d.underline||d.doubleUnderline){const T=Ue(d.color,b);p.fontIndex=e.font.count,e.font.count++,e.font.value=e.font.value+""+(d.bold?"":"")+(d.italic?"":"")+(d.underline||d.doubleUnderline?"":"")+(d.size?'':"")+(T?'':"")+(d.fontFamily?'':"")+"",e.commentSyntax.value[C]=""+(d.bold?"":"")+(d.italic?"":"")+(d.underline||d.doubleUnderline?"":"")+''+(T?'':"")+''}let O="/>";d.alignment&&(d.alignment.rtl&&(d.alignment.readingOrder=2),delete d.alignment.rtl,d.alignment.ltr&&(d.alignment.readingOrder=1),delete d.alignment.ltr,O=' applyAlignment="1">T+" "+K+'="'+d.alignment[K]+'" ',"")+" />");const N=d.border;let P="";if(typeof N=="object"&&((N.left||N.full)&&(P+=''),(N.right||N.full)&&(P+=''),(N.top||N.full)&&(P+=''),(N.bottom||N.full)&&(P+=''),p.borderIndex=e.border.count,e.border.count++,e.border.value+=""+P+""),d.format){const T=o[d.format];T&&(p.formatIndex=T.key,"value"in T&&(e.format.count++,e.format.value+=T.value))}return e.cell.value=e.cell.value+'0?' applyBorder="1" ':"")+(p.fillIndex>0?' applyFill="1" ':"")+(p.fontIndex>=0?' applyFont="1" ':"")+(p.formatIndex>0?' applyNumberFormat="1" ':"")+O,h.styles[C].index=e.cell.count,e.cell.count++,e},{conditionalFormatting:{count:y?1:0,value:' '},commentSyntax:{value:{}},format:{count:0,value:""},border:{count:1,value:""},fill:{count:2,value:""},font:{count:2,value:""},cell:{count:2,value:""}});u==null||u.file("styles.xml",lr(S,y));let I='',E="",R=0,D="",U="",F={};const L={};let V="",k=4,j=!1,n=-1,H=[],te=1;const $={checkbox:` -`};let he=1024;const Z={checkbox:` - - - -
***text***
-
- - - - 0, 2, 0, 2, 0, 86, 1, 0 - False - False - Center - - -
`},oe={checkbox:` - - - - `};let B=[],z="",ne=!1,Q=null;for(let e=0;e=0?C.shiftTop+1:1,T="",K="",J="",q="",re="",ge="",me=!1,Fe="",Ke="",De="",$e="",ye=Object.assign([],C.merges),ze=Object.assign({},C.formula),Ze=Object.assign([],C.conditionalFormatting),Re=!1,Pe=[],Ye="",Ve=[],at=[],Ge=[],He=[],Le={},Je="",Qe=!1,vt="";if(C.rtl&&(re+=' rightToLeft="1" '),C.pageBreak){const ie=C.pageBreak;if(ie.row&&Array.isArray(ie.row)){ge="pageBreakPreview";const M=ie.row.length;vt+=''+ie.row.reduce((ee,Y)=>ee+'',"")+""}if(ie.column&&Array.isArray(ie.column)){ge="pageBreakPreview";const M=ie.column.length;vt+=''+ie.column.reduce((ee,Y)=>ee+'',"")+""}}let qt="";if(C.pageOption){const ie=C.pageOption;if(ie.isPortrait&&(Qe=!0),ie.margin){const ae=ie.margin;let se={left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3};Object.keys(se).forEach(G=>{typeof ae[G]=="number"&&(se[G]=ae[G])}),qt=''}let M="",ee="",Y="",W="";if(["header","footer"].forEach(ae=>{const se=ae.charAt(0).toUpperCase()+ae.substring(1);if(ie[ae]){const G=ie[ae];typeof G=="object"&&Object.keys(G).forEach(le=>{M.indexOf(le)<0&&(M+=le);const Oe=G[le];let xe="";if(Object.keys(Oe).reduce((de,ce)=>(ce=="l"?de.splice(0,0,ce):ce=="c"?de.splice(1,0,ce):ce=="r"&&de.splice(2,0,ce),de),[]).forEach(de=>{const ce=Oe[de];xe+="&"+de.toUpperCase(),ce.styleId&&m[ce.styleId]&&(xe+=m[ce.styleId]),ce.text&&(xe+=ce.text)}),xe="<"+le+se+">"+xe+"",le=="odd")ee+=xe;else if(le=="even")Y+=xe;else if(le=="first")W+=xe;else throw"type error"})}}),Je=ee+Y+W,Je.length>0){Qe=!0;const ae=M.length==7||M.length==12?' differentOddEven="1"':"",se=M.indexOf("first")>=0?' differentFirst="1"':"";Je=""+Je+""}}if(C.viewOption){let ie="";const M=C.viewOption;M.type&&(ge=M.type),M.hideRuler&&(re+=' showRuler="0" '),M.hideGrid&&(re+=' showGridLines="0" '),M.hideHeadlines&&(re+=' showRowColHeaders="0" ');let ee=M.splitOption;if(typeof ee>"u"&&(Qe=!1,typeof M.frozenOption=="object")){const Y=M.frozenOption;if(ie=' state="frozen" ',Y.type=="R"||Y.type=="ROW"){let W;typeof Y.index=="object"?W=Y.index.r:W=Y.index,ee={startAt:{b:"A"+(W+1)},type:"H",split:W}}else if(Y.type=="C"||Y.type=="COLUMN"){let W;typeof Y.index=="object"?W=Y.index.c:W=Y.index,W>r.length-1&&(r=et(r,W)),ee={type:"V",startAt:{r:r[W]+1},split:W}}else if(Y.type=="B"||Y.type=="BOTH"){let W="",fe;typeof Y.index=="number"?(fe=Y.index,W=r[Y.index]+(Y.index+1)):(fe={y:Y.index.r,x:Y.index.c},W=r[Y.index.c]+(Y.index.r+1)),ee={startAt:{two:W},type:"B",split:fe}}}if(ee)if(ee.type=="H"||ee.type=="HORIZONTAL"){let Y;ee.startAt&&(Y=ee.startAt.b,ee.startAt.t&&(re+=' topLeftCell="'+ee.startAt.t+'"')),Y||(Y="A1"),q='"}else if(ee.type=="V"||ee.type=="VERTICAL"){let Y;ee.startAt&&(Y=ee.startAt.r,ee.startAt.l&&(re+=' topLeftCell="'+ee.startAt.l+'"')),Y||(Y="A1"),q='"}else{let Y;ee.startAt&&(Y=ee.startAt.two,ee.startAt.one&&(re+=' topLeftCell="'+ee.startAt.one+'"')),Y||(Y="A1"),q='"}}if(Qe&&(ge="pageLayout"),C.checkbox){me=!0;const ie=$.checkbox;C.checkbox.forEach((M,ee)=>{let Y=ie;if(M.link){let le=qe(M.link,r);Y=Y.replace("**fmlaLink**",'fmlaLink="$'+r[le.col]+"$"+(le.row+1)+'"')}else Y=Y.replace("**fmlaLink**","");M.mixed?Y=Y.replace("**value**",'checked="Mixed"'):M.checked?Y=Y.replace("**value**",'checked="Checked"'):Y=Y.replace("**value**",""),M.threeD&&Y.replace('noThreeD="1"',""),B.push(Y),he++;let W=e+""+he++;const fe="_x0000_s"+W;Ke+=Z.checkbox.replace("***id***",fe).replace("***text***",M.text);let ae=M.startStr,se=M.endStr,G={start:{col:0,row:0},end:{col:1,row:1}};if(M.col&&M.row&&(G={start:{col:M.col,row:M.row-1},end:{col:M.col,row:M.row}}),typeof ae=="string"&&ae.length>=2){let le=qe(ae,r);G.start={...le},G.end={col:le.col+1,row:le.row+1}}if(typeof se=="string"&&se.length>=2){let le=qe(se,r);le.row+=1,le.col+=1,G.end={...le}}$e+=''+G.start.col+"19050"+G.start.row+"19050"+G.end.col+"819150"+G.end.row+"0",De+='',Fe+=''+G.start.col+"19050"+G.start.row+"19050"+G.end.col+"819150"+G.end.row+'0'+M.text+""})}let xt;if(C.backgroundImage){_==null&&(_=u==null?void 0:u.folder("media"));const ie=C.backgroundImage;xt=new Promise(async(M,ee)=>{let Y=ie.lastIndexOf("."),W;Y>0?(W=ie.substring(Y+1).toLowerCase(),W.length>4&&(W.indexOf("gif")>=0?W="gif":W.indexOf("jpg")>=0?W="jpg":W.indexOf("jpeg")>=0?W="jpeg":W="png")):W="png";const fe=te++,ae="image"+fe+"."+W,se=await Rt(ie,ae,b,h.fetch);se||ee("image not load"),H.push(W),M({name:ae,type:W,image:se,ref:fe})})}let wt;if(C.images&&(_==null&&(_=u==null?void 0:u.folder("media")),wt=Promise.all([...C.images.map(async(ie,M)=>{let ee=ie.url.lastIndexOf("."),Y;ee>0?(Y=ie.url.substring(ee+1).toLowerCase(),Y.length>4&&(Y.indexOf("gif")>=0?Y="gif":Y.indexOf("jpg")>=0?Y="jpg":Y.indexOf("jpeg")>=0?Y="jpeg":Y="png")):Y="png",H.push(Y);const W="image"+te+++"."+Y;return{type:Y,image:await Rt(ie.url,W,b,h.fetch),obj:ie,i:M,name:W}})])),Array.isArray(C.headers)&&C.headers.length){const ie=C.headers.length;let M="";if(C.title){const W=C.title,fe=W.comment,ae=W.shiftTop&&W.shiftTop>=0?W.shiftTop:0,se=C.shiftLeft&&C.shiftLeft>=0?C.shiftLeft:0,G=W.shiftLeft&&W.shiftLeft+se>=0?W.shiftLeft+se:se,le=W.consommeRow?W.consommeRow-1:1,Oe=W.consommeCol?W.consommeCol:ie,xe=le==0&&typeof W.height=="number"?' ht="'+W.height+'" customHeight="1" ':"",de=W.styleId?W.styleId:"titleStyle",ce=r[G]+""+(P+ae);if(ye.push(ce+":"+r[G+Oe-1]+(P+le+ae)),typeof fe<"u"){Re=!0;const ke=dt(fe,S.commentSyntax.value,t);let Ne=Pe.length;if(ke.hasAuthor&&typeof ke.author<"u"){let Ce=ke.author.toString();const Ee=Pe.indexOf(Ce);Ee<0?Pe.push(Ce):Ne=Ee}Ve.push({row:P+ae-1,col:G}),Ye+=ut(ce,ke.commentStr,ke.commentStyle,Ne)}typeof W.text=="string"&&(d[P+ae]={startTag:'',details:''+R+"",endTag:""},M+='',M+=''+R+"",M+="",R++,F[W.text]=W.text,W.multiStyleValue&&Array.isArray(W.multiStyleValue)?E+=mt(W.multiStyleValue,S.commentSyntax.value,de):E+=""+tt(W.text)+""),P+=ae+le+1}let ee=C.headerStyleKey?C.headerStyleKey:null,Y=0;if(typeof C.shiftLeft=="number"&&C.shiftLeft>=0&&(Y=C.shiftLeft),O&&(N+='',Q||(Q=u==null?void 0:u.folder("tables"))),p.start=r[Y]+""+P,p.end=r[Y+C.headers.length-1]+""+(P+C.data.length),C.headers.forEach((W,fe)=>{if(O&&(N+=''),Y&&(fe+=Y),W.formula&&Ge.push(fe),W.conditionalFormatting&&y&&He.push(fe),at.push(W.label),C.mergeRowDataCondition&&typeof C.mergeRowDataCondition=="function"&&C.mergeRowDataCondition(W,null,fe,!0)===!0&&(Le[r[fe]]={inProgress:!0,start:P}),C.styleCellCondition&&typeof C.styleCellCondition=="function"&&(ee=C.styleCellCondition(W,W,P,fe,!0,g)||ee),W.size&&W.size>0&&(K+=''),C.withoutHeader)return;const ae=r[fe]+""+P;if(typeof C.commentCondition=="function"){const G=C.commentCondition(W,null,W.label,P,fe,!0);(typeof G=="string"||typeof G=="object"&&G!=null)&&(W.comment=G)}if(W.comment){Re=!0;const G=dt(W.comment,S.commentSyntax.value,t);let le=Pe.length;if(G.hasAuthor&&typeof G.author<"u"){let Oe=G.author.toString();const xe=Pe.indexOf(Oe);xe<0?Pe.push(Oe):le=xe}Ve.push({row:P-1,col:fe}),Ye+=ut(ae,G.commentStr,G.commentStyle,le)}const se=ze&&ze[ae];if(se){const G=ht(ae,se,A,h.styles);G.needCalcChain&&(ne=!0,z+=G.chainCell),T+=G.cell,delete ze[ae]}else{if(T+=''+R+"",typeof C.multiStyleCondition=="function"){const G=C.multiStyleCondition(W,null,W.label,P,fe,!0);G&&(W.multiStyleValue=G)}W.multiStyleValue&&Array.isArray(W.multiStyleValue)?E+=mt(W.multiStyleValue,S.commentSyntax.value,ee||""):E+=""+tt(W.text)+"",F[W.text]=W.text,R++}}),O&&(N+=""),C.withoutHeader)T+=M;else{const W='fe+" "+ae+'="'+C.headerRowOption[ae]+'" '," "):"")+">";d[P]={startTag:W,endTag:"",details:T},T=M+W+T+"",P++}if(Array.isArray(C.data)){const W=C.mapSheetDataOption&&C.mapSheetDataOption.outlineLevel?C.mapSheetDataOption.outlineLevel:"outlineLevel",fe=C.mapSheetDataOption&&C.mapSheetDataOption.hidden?C.mapSheetDataOption.hidden:"hidden",ae=C.mapSheetDataOption&&C.mapSheetDataOption.height?C.mapSheetDataOption.height:"height",se=C.data.length;C.data.forEach((G,le)=>{if(G.mergeType)for(let ce=0;ce
");const N=d.border;let P="";if(typeof N=="object"&&((N.left||N.full)&&(P+=''),(N.right||N.full)&&(P+=''),(N.top||N.full)&&(P+=''),(N.bottom||N.full)&&(P+=''),p.borderIndex=e.border.count,e.border.count++,e.border.value+=""+P+""),d.format){const T=o[d.format];T&&(p.formatIndex=T.key,"value"in T&&(e.format.count++,e.format.value+=T.value))}return e.cell.value=e.cell.value+'0?' applyBorder="1" ':"")+(p.fillIndex>0?' applyFill="1" ':"")+(p.fontIndex>=0?' applyFont="1" ':"")+(p.formatIndex>0?' applyNumberFormat="1" ':"")+O,h.styles[C].index=e.cell.count,e.cell.count++,e},{conditionalFormatting:{count:y?1:0,value:' '},commentSyntax:{value:{}},format:{count:0,value:""},border:{count:1,value:""},fill:{count:2,value:""},font:{count:2,value:""},cell:{count:2,value:""}});u==null||u.file("styles.xml",lr(S,y));let I='',E="",R=0,D="",U="",F={};const L={};let V="",k=4,j=!1,n=-1,H=[],te=1;const $={checkbox:` -`};let he=1024;const Z={checkbox:` - - - -
***text***
-
- - - - 0, 2, 0, 2, 0, 86, 1, 0 - False - False - Center - - -
`},oe={checkbox:` - - - - `};let B=[],z="",ne=!1,Q=null;for(let e=0;e=0?C.shiftTop+1:1,T="",K="",J="",q="",re="",ge="",me=!1,Fe="",Ke="",De="",$e="",ye=Object.assign([],C.merges),ze=Object.assign({},C.formula),Ze=Object.assign([],C.conditionalFormatting),Re=!1,Pe=[],Ve="",Ge=[],st=[],Xe=[],He=[],Le={},Qe="",et=!1,xt="";if(C.rtl&&(re+=' rightToLeft="1" '),C.pageBreak){const ie=C.pageBreak;if(ie.row&&Array.isArray(ie.row)){ge="pageBreakPreview";const M=ie.row.length;xt+=''+ie.row.reduce((ee,Y)=>ee+'',"")+""}if(ie.column&&Array.isArray(ie.column)){ge="pageBreakPreview";const M=ie.column.length;xt+=''+ie.column.reduce((ee,Y)=>ee+'',"")+""}}let qt="";if(C.pageOption){const ie=C.pageOption;if(ie.isPortrait&&(et=!0),ie.margin){const ae=ie.margin;let se={left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3};Object.keys(se).forEach(G=>{typeof ae[G]=="number"&&(se[G]=ae[G])}),qt=''}let M="",ee="",Y="",W="";if(["header","footer"].forEach(ae=>{const se=ae.charAt(0).toUpperCase()+ae.substring(1);if(ie[ae]){const G=ie[ae];typeof G=="object"&&Object.keys(G).forEach(le=>{M.indexOf(le)<0&&(M+=le);const Ie=G[le];let xe="";if(Object.keys(Ie).reduce((de,ce)=>(ce=="l"?de.splice(0,0,ce):ce=="c"?de.splice(1,0,ce):ce=="r"&&de.splice(2,0,ce),de),[]).forEach(de=>{const ce=Ie[de];xe+="&"+de.toUpperCase(),ce.styleId&&m[ce.styleId]&&(xe+=m[ce.styleId]),ce.text&&(xe+=ce.text)}),xe="<"+le+se+">"+xe+"",le=="odd")ee+=xe;else if(le=="even")Y+=xe;else if(le=="first")W+=xe;else throw"type error"})}}),Qe=ee+Y+W,Qe.length>0){et=!0;const ae=M.length==7||M.length==12?' differentOddEven="1"':"",se=M.indexOf("first")>=0?' differentFirst="1"':"";Qe=""+Qe+""}}if(C.viewOption){let ie="";const M=C.viewOption;M.type&&(ge=M.type),M.hideRuler&&(re+=' showRuler="0" '),M.hideGrid&&(re+=' showGridLines="0" '),M.hideHeadlines&&(re+=' showRowColHeaders="0" ');let ee=M.splitOption;if(typeof ee>"u"&&(et=!1,typeof M.frozenOption=="object")){const Y=M.frozenOption;if(ie=' state="frozen" ',Y.type=="R"||Y.type=="ROW"){let W;typeof Y.index=="object"?W=Y.index.r:W=Y.index,ee={startAt:{b:"A"+(W+1)},type:"H",split:W}}else if(Y.type=="C"||Y.type=="COLUMN"){let W;typeof Y.index=="object"?W=Y.index.c:W=Y.index,W>r.length-1&&(r=tt(r,W)),ee={type:"V",startAt:{r:r[W]+1},split:W}}else if(Y.type=="B"||Y.type=="BOTH"){let W="",fe;typeof Y.index=="number"?(fe=Y.index,W=r[Y.index]+(Y.index+1)):(fe={y:Y.index.r,x:Y.index.c},W=r[Y.index.c]+(Y.index.r+1)),ee={startAt:{two:W},type:"B",split:fe}}}if(ee)if(ee.type=="H"||ee.type=="HORIZONTAL"){let Y;ee.startAt&&(Y=ee.startAt.b,ee.startAt.t&&(re+=' topLeftCell="'+ee.startAt.t+'"')),Y||(Y="A1"),q='"}else if(ee.type=="V"||ee.type=="VERTICAL"){let Y;ee.startAt&&(Y=ee.startAt.r,ee.startAt.l&&(re+=' topLeftCell="'+ee.startAt.l+'"')),Y||(Y="A1"),q='"}else{let Y;ee.startAt&&(Y=ee.startAt.two,ee.startAt.one&&(re+=' topLeftCell="'+ee.startAt.one+'"')),Y||(Y="A1"),q='"}}if(et&&(ge="pageLayout"),C.checkbox){me=!0;const ie=$.checkbox;C.checkbox.forEach((M,ee)=>{let Y=ie;if(M.link){let le=Ye(M.link,r);Y=Y.replace("**fmlaLink**",'fmlaLink="$'+r[le.col]+"$"+(le.row+1)+'"')}else Y=Y.replace("**fmlaLink**","");M.mixed?Y=Y.replace("**value**",'checked="Mixed"'):M.checked?Y=Y.replace("**value**",'checked="Checked"'):Y=Y.replace("**value**",""),M.threeD&&Y.replace('noThreeD="1"',""),B.push(Y),he++;let W=e+""+he++;const fe="_x0000_s"+W;Ke+=Z.checkbox.replace("***id***",fe).replace("***text***",M.text);let ae=M.startStr,se=M.endStr,G={start:{col:0,row:0},end:{col:1,row:1}};if(M.col&&M.row&&(G={start:{col:M.col,row:M.row-1},end:{col:M.col,row:M.row}}),typeof ae=="string"&&ae.length>=2){let le=Ye(ae,r);G.start={...le},G.end={col:le.col+1,row:le.row+1}}if(typeof se=="string"&&se.length>=2){let le=Ye(se,r);le.row+=1,le.col+=1,G.end={...le}}$e+=''+G.start.col+"19050"+G.start.row+"19050"+G.end.col+"819150"+G.end.row+"0",De+='',Fe+=''+G.start.col+"19050"+G.start.row+"19050"+G.end.col+"819150"+G.end.row+'0'+M.text+""})}let wt;if(C.backgroundImage){_==null&&(_=u==null?void 0:u.folder("media"));const ie=C.backgroundImage;wt=new Promise(async(M,ee)=>{let Y=ie.lastIndexOf("."),W;Y>0?(W=ie.substring(Y+1).toLowerCase(),W.length>4&&(W.indexOf("gif")>=0?W="gif":W.indexOf("jpg")>=0?W="jpg":W.indexOf("jpeg")>=0?W="jpeg":W="png")):W="png";const fe=te++,ae="image"+fe+"."+W,se=await Rt(ie,ae,b,h.fetch);se||ee("image not load"),H.push(W),M({name:ae,type:W,image:se,ref:fe})})}let Ct;if(C.images&&(_==null&&(_=u==null?void 0:u.folder("media")),Ct=Promise.all([...C.images.map(async(ie,M)=>{let ee=ie.url.lastIndexOf("."),Y;ee>0?(Y=ie.url.substring(ee+1).toLowerCase(),Y.length>4&&(Y.indexOf("gif")>=0?Y="gif":Y.indexOf("jpg")>=0?Y="jpg":Y.indexOf("jpeg")>=0?Y="jpeg":Y="png")):Y="png",H.push(Y);const W="image"+te+++"."+Y;return{type:Y,image:await Rt(ie.url,W,b,h.fetch),obj:ie,i:M,name:W}})])),Array.isArray(C.headers)&&C.headers.length){const ie=C.headers.length;let M="";if(C.title){const W=C.title,fe=W.comment,ae=W.shiftTop&&W.shiftTop>=0?W.shiftTop:0,se=C.shiftLeft&&C.shiftLeft>=0?C.shiftLeft:0,G=W.shiftLeft&&W.shiftLeft+se>=0?W.shiftLeft+se:se,le=W.consommeRow?W.consommeRow-1:1,Ie=W.consommeCol?W.consommeCol:ie,xe=le==0&&typeof W.height=="number"?' ht="'+W.height+'" customHeight="1" ':"",de=W.styleId?W.styleId:"titleStyle",ce=r[G]+""+(P+ae);if(ye.push(ce+":"+r[G+Ie-1]+(P+le+ae)),typeof fe<"u"){Re=!0;const ke=ut(fe,S.commentSyntax.value,t);let Ne=Pe.length;if(ke.hasAuthor&&typeof ke.author<"u"){let Ce=ke.author.toString();const Te=Pe.indexOf(Ce);Te<0?Pe.push(Ce):Ne=Te}Ge.push({row:P+ae-1,col:G}),Ve+=mt(ce,ke.commentStr,ke.commentStyle,Ne)}typeof W.text=="string"&&(d[P+ae]={startTag:'',details:''+R+"",endTag:""},M+='',M+=''+R+"",M+="",R++,F[W.text]=W.text,W.multiStyleValue&&Array.isArray(W.multiStyleValue)?E+=pt(W.multiStyleValue,S.commentSyntax.value,de):E+=""+rt(W.text)+""),P+=ae+le+1}let ee=C.headerStyleKey?C.headerStyleKey:null,Y=0;if(typeof C.shiftLeft=="number"&&C.shiftLeft>=0&&(Y=C.shiftLeft),O&&(N+='',Q||(Q=u==null?void 0:u.folder("tables"))),p.start=r[Y]+""+P,p.end=r[Y+C.headers.length-1]+""+(P+C.data.length),C.headers.forEach((W,fe)=>{if(O&&(N+=''),Y&&(fe+=Y),W.formula&&Xe.push(fe),W.conditionalFormatting&&y&&He.push(fe),st.push(W.label),C.mergeRowDataCondition&&typeof C.mergeRowDataCondition=="function"&&C.mergeRowDataCondition(W,null,fe,!0)===!0&&(Le[r[fe]]={inProgress:!0,start:P}),C.styleCellCondition&&typeof C.styleCellCondition=="function"&&(ee=C.styleCellCondition(W,W,P,fe,!0,g)||ee),W.size&&W.size>0&&(K+=''),C.withoutHeader)return;const ae=r[fe]+""+P;if(typeof C.commentCondition=="function"){const G=C.commentCondition(W,null,W.label,P,fe,!0);(typeof G=="string"||typeof G=="object"&&G!=null)&&(W.comment=G)}if(W.comment){Re=!0;const G=ut(W.comment,S.commentSyntax.value,t);let le=Pe.length;if(G.hasAuthor&&typeof G.author<"u"){let Ie=G.author.toString();const xe=Pe.indexOf(Ie);xe<0?Pe.push(Ie):le=xe}Ge.push({row:P-1,col:fe}),Ve+=mt(ae,G.commentStr,G.commentStyle,le)}const se=ze&&ze[ae];if(se){const G=dt(ae,se,A,h.styles);G.needCalcChain&&(ne=!0,z+=G.chainCell),T+=G.cell,delete ze[ae]}else{if(T+=''+R+"",typeof C.multiStyleCondition=="function"){const G=C.multiStyleCondition(W,null,W.label,P,fe,!0);G&&(W.multiStyleValue=G)}W.multiStyleValue&&Array.isArray(W.multiStyleValue)?E+=pt(W.multiStyleValue,S.commentSyntax.value,ee||""):E+=""+rt(W.text)+"",F[W.text]=W.text,R++}}),O&&(N+=""),C.withoutHeader)T+=M;else{const W='fe+" "+ae+'="'+C.headerRowOption[ae]+'" '," "):"")+">";d[P]={startTag:W,endTag:"",details:T},T=M+W+T+"",P++}if(Array.isArray(C.data)){const W=C.mapSheetDataOption&&C.mapSheetDataOption.outlineLevel?C.mapSheetDataOption.outlineLevel:"outlineLevel",fe=C.mapSheetDataOption&&C.mapSheetDataOption.hidden?C.mapSheetDataOption.hidden:"hidden",ae=C.mapSheetDataOption&&C.mapSheetDataOption.height?C.mapSheetDataOption.height:"height",se=C.data.length;C.data.forEach((G,le)=>{if(G.mergeType)for(let ce=0;ce
");const H=x.border;let k="";if(typeof H=="object"&&((H.left||H.full)&&(k+=''),(H.right||H.full)&&(k+=''),(H.top||H.full)&&(k+=''),(H.bottom||H.full)&&(k+=''),Y.borderIndex=w.border.count,w.border.count++,w.border.value+=""+k+""),x.format){const C=r[x.format];C&&(Y.formatIndex=C.key,"value"in C&&(w.format.count++,w.format.value+=C.value))}return w.cell.value=w.cell.value+'0?' applyBorder="1" ':"")+(Y.fillIndex>0?' applyFill="1" ':"")+(Y.fontIndex>=0?' applyFont="1" ':"")+(Y.formatIndex>0?' applyNumberFormat="1" ':"")+se,e.styles[a].index=w.cell.count,w.cell.count++,w},{conditionalFormatting:{count:G?1:0,value:' '},commentSyntax:{value:{}},format:{count:0,value:""},border:{count:1,value:""},fill:{count:2,value:""},font:{count:2,value:""},cell:{count:2,value:""}});f==null||f.file("styles.xml",Zt(N,G));let oe='',P="",B=0,X="",K="",L={};const E={};let $="",q=4,U=!1,M=-1,ve=[],J=1;const ge={checkbox:` +`};let we=1024;const Te={checkbox:` + + + +
***text***
+
+ + + + 0, 2, 0, 2, 0, 86, 1, 0 + False + False + Center + + +
`},ke={checkbox:` + + + + `};let ae=[],ie="",xe=!1,pe=null;for(let w=0;w=0?a.shiftTop+1:1,C="",W="",fe="",Ee="",Se="",je="",nt=!1,_t="",It="",Pt="",jt="",be=Object.assign([],a.merges),ue=Object.assign({},a.formula),lt=Object.assign([],a.conditionalFormatting),Re=!1,he=[],Me="",qe=[],Rt=[],at=[],it=[],Oe={},De="",Le=!1,st="";if(a.rtl&&(Se+=' rightToLeft="1" '),a.pageBreak){const T=a.pageBreak;if(T.row&&Array.isArray(T.row)){je="pageBreakPreview";const i=T.row.length;st+=''+T.row.reduce((y,p)=>y+'',"")+""}if(T.column&&Array.isArray(T.column)){je="pageBreakPreview";const i=T.column.length;st+=''+T.column.reduce((y,p)=>y+'',"")+""}}let Dt="";if(a.pageOption){const T=a.pageOption;if(T.isPortrait&&(Le=!0),T.margin){const F=T.margin;let A={left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3};Object.keys(A).forEach(h=>{typeof F[h]=="number"&&(A[h]=F[h])}),Dt=''}let i="",y="",p="",c="";if(["header","footer"].forEach(F=>{const A=F.charAt(0).toUpperCase()+F.substring(1);if(T[F]){const h=T[F];typeof h=="object"&&Object.keys(h).forEach(O=>{i.indexOf(O)<0&&(i+=O);const le=h[O];let V="";if(Object.keys(le).reduce((R,I)=>(I=="l"?R.splice(0,0,I):I=="c"?R.splice(1,0,I):I=="r"&&R.splice(2,0,I),R),[]).forEach(R=>{const I=le[R];V+="&"+R.toUpperCase(),I.styleId&&z[I.styleId]&&(V+=z[I.styleId]),I.text&&(V+=I.text)}),V="<"+O+A+">"+V+"",O=="odd")y+=V;else if(O=="even")p+=V;else if(O=="first")c+=V;else throw"type error"})}}),De=y+p+c,De.length>0){Le=!0;const F=i.length==7||i.length==12?' differentOddEven="1"':"",A=i.indexOf("first")>=0?' differentFirst="1"':"";De=""+De+""}}if(a.viewOption){let T="";const i=a.viewOption;i.type&&(je=i.type),i.hideRuler&&(Se+=' showRuler="0" '),i.hideGrid&&(Se+=' showGridLines="0" '),i.hideHeadlines&&(Se+=' showRowColHeaders="0" ');let y=i.splitOption;if(typeof y>"u"&&(Le=!1,typeof i.frozenOption=="object")){const p=i.frozenOption;if(T=' state="frozen" ',p.type=="R"||p.type=="ROW"){let c;typeof p.index=="object"?c=p.index.r:c=p.index,y={startAt:{b:"A"+(c+1)},type:"H",split:c}}else if(p.type=="C"||p.type=="COLUMN"){let c;typeof p.index=="object"?c=p.index.c:c=p.index,c>l.length-1&&(l=He(l,c)),y={type:"V",startAt:{r:l[c]+1},split:c}}else if(p.type=="B"||p.type=="BOTH"){let c="",_;typeof p.index=="number"?(_=p.index,c=l[p.index]+(p.index+1)):(_={y:p.index.r,x:p.index.c},c=l[p.index.c]+(p.index.r+1)),y={startAt:{two:c},type:"B",split:_}}}if(y)if(y.type=="H"||y.type=="HORIZONTAL"){let p;y.startAt&&(p=y.startAt.b,y.startAt.t&&(Se+=' topLeftCell="'+y.startAt.t+'"')),p||(p="A1"),Ee='"}else if(y.type=="V"||y.type=="VERTICAL"){let p;y.startAt&&(p=y.startAt.r,y.startAt.l&&(Se+=' topLeftCell="'+y.startAt.l+'"')),p||(p="A1"),Ee='"}else{let p;y.startAt&&(p=y.startAt.two,y.startAt.one&&(Se+=' topLeftCell="'+y.startAt.one+'"')),p||(p="A1"),Ee='"}}if(Le&&(je="pageLayout"),a.checkbox){nt=!0;const T=ge.checkbox;a.checkbox.forEach((i,y)=>{let p=T;if(i.link){let O=Fe(i.link,l);p=p.replace("**fmlaLink**",'fmlaLink="$'+l[O.col]+"$"+(O.row+1)+'"')}else p=p.replace("**fmlaLink**","");i.mixed?p=p.replace("**value**",'checked="Mixed"'):i.checked?p=p.replace("**value**",'checked="Checked"'):p=p.replace("**value**",""),i.threeD&&p.replace('noThreeD="1"',""),ae.push(p),we++;let c=w+""+we++;const _="_x0000_s"+c;It+=Te.checkbox.replace("***id***",_).replace("***text***",i.text);let F=i.startStr,A=i.endStr,h={start:{col:0,row:0},end:{col:1,row:1}};if(i.col&&i.row&&(h={start:{col:i.col,row:i.row-1},end:{col:i.col,row:i.row}}),typeof F=="string"&&F.length>=2){let O=Fe(F,l);h.start={...O},h.end={col:O.col+1,row:O.row+1}}if(typeof A=="string"&&A.length>=2){let O=Fe(A,l);O.row+=1,O.col+=1,h.end={...O}}jt+=''+h.start.col+"19050"+h.start.row+"19050"+h.end.col+"819150"+h.end.row+"0",Pt+='',_t+=''+h.start.col+"19050"+h.start.row+"19050"+h.end.col+"819150"+h.end.row+'0'+i.text+""})}let ct;if(a.backgroundImage){v==null&&(v=f==null?void 0:f.folder("media"));const T=a.backgroundImage;ct=new Promise(async(i,y)=>{let p=T.lastIndexOf("."),c;p>0?(c=T.substring(p+1).toLowerCase(),c.length>4&&(c.indexOf("gif")>=0?c="gif":c.indexOf("jpg")>=0?c="jpg":c.indexOf("jpeg")>=0?c="jpeg":c="png")):c="png";const _=J++,F="image"+_+"."+c,A=await bt(T,F,o,e.fetch);A||y("image not load"),ve.push(c),i({name:F,type:c,image:A,ref:_})})}let ft;if(a.images&&(v==null&&(v=f==null?void 0:f.folder("media")),ft=Promise.all([...a.images.map(async(T,i)=>{let y=T.url.lastIndexOf("."),p;y>0?(p=T.url.substring(y+1).toLowerCase(),p.length>4&&(p.indexOf("gif")>=0?p="gif":p.indexOf("jpg")>=0?p="jpg":p.indexOf("jpeg")>=0?p="jpeg":p="png")):p="png",ve.push(p);const c="image"+J+++"."+p;return{type:p,image:await bt(T.url,c,o,e.fetch),obj:T,i,name:c}})])),Array.isArray(a.headers)&&a.headers.length){const T=a.headers.length;let i="";if(a.title){const c=a.title,_=c.comment,F=c.shiftTop&&c.shiftTop>=0?c.shiftTop:0,A=a.shiftLeft&&a.shiftLeft>=0?a.shiftLeft:0,h=c.shiftLeft&&c.shiftLeft+A>=0?c.shiftLeft+A:A,O=c.consommeRow?c.consommeRow-1:1,le=c.consommeCol?c.consommeCol:T,V=O==0&&typeof c.height=="number"?' ht="'+c.height+'" customHeight="1" ':"",R=c.styleId?c.styleId:"titleStyle",I=l[h]+""+(k+F);if(be.push(I+":"+l[h+le-1]+(k+O+F)),typeof _<"u"){Re=!0;const Q=Ge(_,N.commentSyntax.value,d);let me=he.length;if(Q.hasAuthor&&typeof Q.author<"u"){let ee=Q.author.toString();const re=he.indexOf(ee);re<0?he.push(ee):me=re}qe.push({row:k+F-1,col:h}),Me+=Ze(I,Q.commentStr,Q.commentStyle,me)}typeof c.text=="string"&&(x[k+F]={startTag:'',details:''+B+"",endTag:""},i+='',i+=''+B+"",i+="",B++,L[c.text]=c.text,c.multiStyleValue&&Array.isArray(c.multiStyleValue)?P+=Xe(c.multiStyleValue,N.commentSyntax.value,R):P+=""+Ne(c.text)+""),k+=F+O+1}let y=a.headerStyleKey?a.headerStyleKey:null,p=0;if(typeof a.shiftLeft=="number"&&a.shiftLeft>=0&&(p=a.shiftLeft),se&&(H+='',pe||(pe=f==null?void 0:f.folder("tables"))),Y.start=l[p]+""+k,Y.end=l[p+a.headers.length-1]+""+(k+a.data.length),a.headers.forEach((c,_)=>{if(se&&(H+=''),p&&(_+=p),c.formula&&at.push(_),c.conditionalFormatting&&it.push(_),Rt.push(c.label),a.mergeRowDataCondition&&typeof a.mergeRowDataCondition=="function"&&a.mergeRowDataCondition(c,null,_,!0)===!0&&(Oe[l[_]]={inProgress:!0,start:k}),a.styleCellCondition&&typeof a.styleCellCondition=="function"&&(y=a.styleCellCondition(c,c,k,_,!0,S)||y),c.size&&c.size>0&&(W+=''),a.withoutHeader)return;const F=l[_]+""+k;if(typeof a.commentCondition=="function"){const h=a.commentCondition(c,null,c.label,k,_,!0);(typeof h=="string"||typeof h=="object"&&h!=null)&&(c.comment=h)}if(c.comment){Re=!0;const h=Ge(c.comment,N.commentSyntax.value,d);let O=he.length;if(h.hasAuthor&&typeof h.author<"u"){let le=h.author.toString();const V=he.indexOf(le);V<0?he.push(le):O=V}qe.push({row:k-1,col:_}),Me+=Ze(F,h.commentStr,h.commentStyle,O)}const A=ue&&ue[F];if(A){const h=We(F,A,b,e.styles);h.needCalcChain&&(xe=!0,ie+=h.chainCell),C+=h.cell,delete ue[F]}else{if(C+=''+B+"",typeof a.multiStyleCondition=="function"){const h=a.multiStyleCondition(c,null,c.label,k,_,!0);h&&(c.multiStyleValue=h)}c.multiStyleValue&&Array.isArray(c.multiStyleValue)?P+=Xe(c.multiStyleValue,N.commentSyntax.value,y||""):P+=""+Ne(c.text)+"",L[c.text]=c.text,B++}}),se&&(H+=""),a.withoutHeader)C+=i;else{const c='_+" "+F+'="'+a.headerRowOption[F]+'" '," "):"")+">";x[k]={startTag:c,endTag:"",details:C},C=i+c+C+"",k++}if(Array.isArray(a.data)){const c=a.mapSheetDataOption&&a.mapSheetDataOption.outlineLevel?a.mapSheetDataOption.outlineLevel:"outlineLevel",_=a.mapSheetDataOption&&a.mapSheetDataOption.hidden?a.mapSheetDataOption.hidden:"hidden",F=a.mapSheetDataOption&&a.mapSheetDataOption.height?a.mapSheetDataOption.height:"height",A=a.data.length;a.data.forEach((h,O)=>{if(h.mergeType)for(let I=0;I
");const H=x.border;let k="";if(typeof H=="object"&&((H.left||H.full)&&(k+=''),(H.right||H.full)&&(k+=''),(H.top||H.full)&&(k+=''),(H.bottom||H.full)&&(k+=''),V.borderIndex=w.border.count,w.border.count++,w.border.value+=""+k+""),x.format){const C=r[x.format];C&&(V.formatIndex=C.key,"value"in C&&(w.format.count++,w.format.value+=C.value))}return w.cell.value=w.cell.value+'0?' applyBorder="1" ':"")+(V.fillIndex>0?' applyFill="1" ':"")+(V.fontIndex>=0?' applyFont="1" ':"")+(V.formatIndex>0?' applyNumberFormat="1" ':"")+ce,e.styles[a].index=w.cell.count,w.cell.count++,w},{conditionalFormatting:{count:G?1:0,value:' '},commentSyntax:{value:{}},format:{count:0,value:""},border:{count:1,value:""},fill:{count:2,value:""},font:{count:2,value:""},cell:{count:2,value:""}});f==null||f.file("styles.xml",Jt(N,G));let oe='',P="",B=0,J="",K="",L={};const T={};let $="",Y=4,U=!1,M=-1,we=[],X=1;const xe={checkbox:` +`};let Te=1024;const Ee={checkbox:` + + + +
***text***
+
+ + + + 0, 2, 0, 2, 0, 86, 1, 0 + False + False + Center + + +
`},Oe={checkbox:` + + + + `};let ie=[],se="",be=!1,he=null;for(let w=0;w=0?a.shiftTop+1:1,C="",W="",me="",Se="",ke="",je="",nt=!1,It="",Pt="",jt="",Rt="",Ce=Object.assign([],a.merges),ye=Object.assign({},a.formula),lt=Object.assign([],a.conditionalFormatting),Re=!1,ue=[],Me="",Ye=[],Dt=[],at=[],it=[],Fe={},De="",Le=!1,st="";if(a.rtl&&(ke+=' rightToLeft="1" '),a.pageBreak){const E=a.pageBreak;if(E.row&&Array.isArray(E.row)){je="pageBreakPreview";const s=E.row.length;st+=''+E.row.reduce((y,p)=>y+'',"")+""}if(E.column&&Array.isArray(E.column)){je="pageBreakPreview";const s=E.column.length;st+=''+E.column.reduce((y,p)=>y+'',"")+""}}let Lt="";if(a.pageOption){const E=a.pageOption;if(E.isPortrait&&(Le=!0),E.margin){const F=E.margin;let A={left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3};Object.keys(A).forEach(h=>{typeof F[h]=="number"&&(A[h]=F[h])}),Lt=''}let s="",y="",p="",c="";if(["header","footer"].forEach(F=>{const A=F.charAt(0).toUpperCase()+F.substring(1);if(E[F]){const h=E[F];typeof h=="object"&&Object.keys(h).forEach(O=>{s.indexOf(O)<0&&(s+=O);const le=h[O];let q="";if(Object.keys(le).reduce((D,I)=>(I=="l"?D.splice(0,0,I):I=="c"?D.splice(1,0,I):I=="r"&&D.splice(2,0,I),D),[]).forEach(D=>{const I=le[D];q+="&"+D.toUpperCase(),I.styleId&&z[I.styleId]&&(q+=z[I.styleId]),I.text&&(q+=I.text)}),q="<"+O+A+">"+q+"",O=="odd")y+=q;else if(O=="even")p+=q;else if(O=="first")c+=q;else throw"type error"})}}),De=y+p+c,De.length>0){Le=!0;const F=s.length==7||s.length==12?' differentOddEven="1"':"",A=s.indexOf("first")>=0?' differentFirst="1"':"";De=""+De+""}}if(a.viewOption){let E="";const s=a.viewOption;s.type&&(je=s.type),s.hideRuler&&(ke+=' showRuler="0" '),s.hideGrid&&(ke+=' showGridLines="0" '),s.hideHeadlines&&(ke+=' showRowColHeaders="0" ');let y=s.splitOption;if(typeof y>"u"&&(Le=!1,typeof s.frozenOption=="object")){const p=s.frozenOption;if(E=' state="frozen" ',p.type=="R"||p.type=="ROW"){let c;typeof p.index=="object"?c=p.index.r:c=p.index,y={startAt:{b:"A"+(c+1)},type:"H",split:c}}else if(p.type=="C"||p.type=="COLUMN"){let c;typeof p.index=="object"?c=p.index.c:c=p.index,c>l.length-1&&(l=He(l,c)),y={type:"V",startAt:{r:l[c]+1},split:c}}else if(p.type=="B"||p.type=="BOTH"){let c="",_;typeof p.index=="number"?(_=p.index,c=l[p.index]+(p.index+1)):(_={y:p.index.r,x:p.index.c},c=l[p.index.c]+(p.index.r+1)),y={startAt:{two:c},type:"B",split:_}}}if(y)if(y.type=="H"||y.type=="HORIZONTAL"){let p;y.startAt&&(p=y.startAt.b,y.startAt.t&&(ke+=' topLeftCell="'+y.startAt.t+'"')),p||(p="A1"),Se='"}else if(y.type=="V"||y.type=="VERTICAL"){let p;y.startAt&&(p=y.startAt.r,y.startAt.l&&(ke+=' topLeftCell="'+y.startAt.l+'"')),p||(p="A1"),Se='"}else{let p;y.startAt&&(p=y.startAt.two,y.startAt.one&&(ke+=' topLeftCell="'+y.startAt.one+'"')),p||(p="A1"),Se='"}}if(Le&&(je="pageLayout"),a.checkbox){nt=!0;const E=xe.checkbox;a.checkbox.forEach((s,y)=>{let p=E;if(s.link){let O=Ae(s.link,l);p=p.replace("**fmlaLink**",'fmlaLink="$'+l[O.col]+"$"+(O.row+1)+'"')}else p=p.replace("**fmlaLink**","");s.mixed?p=p.replace("**value**",'checked="Mixed"'):s.checked?p=p.replace("**value**",'checked="Checked"'):p=p.replace("**value**",""),s.threeD&&p.replace('noThreeD="1"',""),ie.push(p),Te++;let c=w+""+Te++;const _="_x0000_s"+c;Pt+=Ee.checkbox.replace("***id***",_).replace("***text***",s.text);let F=s.startStr,A=s.endStr,h={start:{col:0,row:0},end:{col:1,row:1}};if(s.col&&s.row&&(h={start:{col:s.col,row:s.row-1},end:{col:s.col,row:s.row}}),typeof F=="string"&&F.length>=2){let O=Ae(F,l);h.start={...O},h.end={col:O.col+1,row:O.row+1}}if(typeof A=="string"&&A.length>=2){let O=Ae(A,l);O.row+=1,O.col+=1,h.end={...O}}Rt+=''+h.start.col+"19050"+h.start.row+"19050"+h.end.col+"819150"+h.end.row+"0",jt+='',It+=''+h.start.col+"19050"+h.start.row+"19050"+h.end.col+"819150"+h.end.row+'0'+s.text+""})}let ct;if(a.backgroundImage){v==null&&(v=f==null?void 0:f.folder("media"));const E=a.backgroundImage;ct=new Promise(async(s,y)=>{let p=E.lastIndexOf("."),c;p>0?(c=E.substring(p+1).toLowerCase(),c.length>4&&(c.indexOf("gif")>=0?c="gif":c.indexOf("jpg")>=0?c="jpg":c.indexOf("jpeg")>=0?c="jpeg":c="png")):c="png";const _=X++,F="image"+_+"."+c,A=await Ct(E,F,o,e.fetch);A||y("image not load"),we.push(c),s({name:F,type:c,image:A,ref:_})})}let ft;if(a.images&&(v==null&&(v=f==null?void 0:f.folder("media")),ft=Promise.all([...a.images.map(async(E,s)=>{let y=E.url.lastIndexOf("."),p;y>0?(p=E.url.substring(y+1).toLowerCase(),p.length>4&&(p.indexOf("gif")>=0?p="gif":p.indexOf("jpg")>=0?p="jpg":p.indexOf("jpeg")>=0?p="jpeg":p="png")):p="png",we.push(p);const c="image"+X+++"."+p;return{type:p,image:await Ct(E.url,c,o,e.fetch),obj:E,i:s,name:c}})])),Array.isArray(a.headers)&&a.headers.length){const E=a.headers.length;let s="";if(a.title){const c=a.title,_=c.comment,F=c.shiftTop&&c.shiftTop>=0?c.shiftTop:0,A=a.shiftLeft&&a.shiftLeft>=0?a.shiftLeft:0,h=c.shiftLeft&&c.shiftLeft+A>=0?c.shiftLeft+A:A,O=c.consommeRow?c.consommeRow-1:1,le=c.consommeCol?c.consommeCol:E,q=O==0&&typeof c.height=="number"?' ht="'+c.height+'" customHeight="1" ':"",D=c.styleId?c.styleId:"titleStyle",I=l[h]+""+(k+F);if(Ce.push(I+":"+l[h+le-1]+(k+O+F)),typeof _<"u"){Re=!0;const Q=Ge(_,N.commentSyntax.value,d);let de=ue.length;if(Q.hasAuthor&&typeof Q.author<"u"){let ee=Q.author.toString();const re=ue.indexOf(ee);re<0?ue.push(ee):de=re}Ye.push({row:k+F-1,col:h}),Me+=Ze(I,Q.commentStr,Q.commentStyle,de)}typeof c.text=="string"&&(x[k+F]={startTag:'',details:''+B+"",endTag:""},s+='',s+=''+B+"",s+="",B++,L[c.text]=c.text,c.multiStyleValue&&Array.isArray(c.multiStyleValue)?P+=Je(c.multiStyleValue,N.commentSyntax.value,D):P+=""+Ne(c.text)+""),k+=F+O+1}let y=a.headerStyleKey?a.headerStyleKey:null,p=0;if(typeof a.shiftLeft=="number"&&a.shiftLeft>=0&&(p=a.shiftLeft),ce&&(H+='',he||(he=f==null?void 0:f.folder("tables"))),V.start=l[p]+""+k,V.end=l[p+a.headers.length-1]+""+(k+a.data.length),a.headers.forEach((c,_)=>{if(ce&&(H+=''),p&&(_+=p),c.formula&&at.push(_),c.conditionalFormatting&&it.push(_),Dt.push(c.label),a.mergeRowDataCondition&&typeof a.mergeRowDataCondition=="function"&&a.mergeRowDataCondition(c,null,_,!0)===!0&&(Fe[l[_]]={inProgress:!0,start:k}),a.styleCellCondition&&typeof a.styleCellCondition=="function"&&(y=a.styleCellCondition(c,c,k,_,!0,S)||y),c.size&&c.size>0&&(W+=''),a.withoutHeader)return;const F=l[_]+""+k;if(typeof a.commentCondition=="function"){const h=a.commentCondition(c,null,c.label,k,_,!0);(typeof h=="string"||typeof h=="object"&&h!=null)&&(c.comment=h)}if(c.comment){Re=!0;const h=Ge(c.comment,N.commentSyntax.value,d);let O=ue.length;if(h.hasAuthor&&typeof h.author<"u"){let le=h.author.toString();const q=ue.indexOf(le);q<0?ue.push(le):O=q}Ye.push({row:k-1,col:_}),Me+=Ze(F,h.commentStr,h.commentStyle,O)}const A=ye&&ye[F];if(A){const h=We(F,A,b,e.styles);h.needCalcChain&&(be=!0,se+=h.chainCell),C+=h.cell,delete ye[F]}else{if(C+=''+B+"",typeof a.multiStyleCondition=="function"){const h=a.multiStyleCondition(c,null,c.label,k,_,!0);h&&(c.multiStyleValue=h)}c.multiStyleValue&&Array.isArray(c.multiStyleValue)?P+=Je(c.multiStyleValue,N.commentSyntax.value,y||""):P+=""+Ne(c.text)+"",L[c.text]=c.text,B++}}),ce&&(H+=""),a.withoutHeader)C+=s;else{const c='_+" "+F+'="'+a.headerRowOption[F]+'" '," "):"")+">";x[k]={startTag:c,endTag:"",details:C},C=s+c+C+"",k++}if(Array.isArray(a.data)){const c=a.mapSheetDataOption&&a.mapSheetDataOption.outlineLevel?a.mapSheetDataOption.outlineLevel:"outlineLevel",_=a.mapSheetDataOption&&a.mapSheetDataOption.hidden?a.mapSheetDataOption.hidden:"hidden",F=a.mapSheetDataOption&&a.mapSheetDataOption.height?a.mapSheetDataOption.height:"height",A=a.data.length;a.data.forEach((h,O)=>{if(h.mergeType)for(let I=0;I
");const H=x.border;let k="";if(typeof H=="object"&&((H.left||H.full)&&(k+=''),(H.right||H.full)&&(k+=''),(H.top||H.full)&&(k+=''),(H.bottom||H.full)&&(k+=''),Y.borderIndex=w.border.count,w.border.count++,w.border.value+=""+k+""),x.format){const C=r[x.format];C&&(Y.formatIndex=C.key,"value"in C&&(w.format.count++,w.format.value+=C.value))}return w.cell.value=w.cell.value+'0?' applyBorder="1" ':"")+(Y.fillIndex>0?' applyFill="1" ':"")+(Y.fontIndex>=0?' applyFont="1" ':"")+(Y.formatIndex>0?' applyNumberFormat="1" ':"")+se,e.styles[a].index=w.cell.count,w.cell.count++,w},{conditionalFormatting:{count:G?1:0,value:' '},commentSyntax:{value:{}},format:{count:0,value:""},border:{count:1,value:""},fill:{count:2,value:""},font:{count:2,value:""},cell:{count:2,value:""}});f==null||f.file("styles.xml",Jt(N,G));let oe='',P="",B=0,J="",K="",L={};const E={};let $="",M=4,U=!1,q=-1,Ce=[],X=1;const ye={checkbox:` +`};let ve=1024;const we={checkbox:` + + + +
***text***
+
+ + + + 0, 2, 0, 2, 0, 86, 1, 0 + False + False + Center + + +
`},Se={checkbox:` + + + + `};let ae=[],ie="",ge=!1,de=null;for(let w=0;w=0?a.shiftTop+1:1,C="",W="",ce="",Te="",Ee="",Ie="",Ue=!1,dt="",pt="",ht="",ut="",xe=Object.assign([],a.merges),ue=Object.assign({},a.formula),We=Object.assign([],a.conditionalFormatting),Pe=!1,pe=[],Le="",He=[],yt=[],Ge=[],Ze=[],ke={},je="",Re=!1,Je="";if(a.rtl&&(Ee+=' rightToLeft="1" '),a.pageBreak){const T=a.pageBreak;if(T.row&&Array.isArray(T.row)){Ie="pageBreakPreview";const i=T.row.length;Je+=''+T.row.reduce((y,p)=>y+'',"")+""}if(T.column&&Array.isArray(T.column)){Ie="pageBreakPreview";const i=T.column.length;Je+=''+T.column.reduce((y,p)=>y+'',"")+""}}let gt="";if(a.pageOption){const T=a.pageOption;if(T.isPortrait&&(Re=!0),T.margin){const F=T.margin;let A={left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3};Object.keys(A).forEach(h=>{typeof F[h]=="number"&&(A[h]=F[h])}),gt=''}let i="",y="",p="",c="";if(["header","footer"].forEach(F=>{const A=F.charAt(0).toUpperCase()+F.substring(1);if(T[F]){const h=T[F];typeof h=="object"&&Object.keys(h).forEach(O=>{i.indexOf(O)<0&&(i+=O);const le=h[O];let V="";if(Object.keys(le).reduce((R,I)=>(I=="l"?R.splice(0,0,I):I=="c"?R.splice(1,0,I):I=="r"&&R.splice(2,0,I),R),[]).forEach(R=>{const I=le[R];V+="&"+R.toUpperCase(),I.styleId&&z[I.styleId]&&(V+=z[I.styleId]),I.text&&(V+=I.text)}),V="<"+O+A+">"+V+"",O=="odd")y+=V;else if(O=="even")p+=V;else if(O=="first")c+=V;else throw"type error"})}}),je=y+p+c,je.length>0){Re=!0;const F=i.length==7||i.length==12?' differentOddEven="1"':"",A=i.indexOf("first")>=0?' differentFirst="1"':"";je=""+je+""}}if(a.viewOption){let T="";const i=a.viewOption;i.type&&(Ie=i.type),i.hideRuler&&(Ee+=' showRuler="0" '),i.hideGrid&&(Ee+=' showGridLines="0" '),i.hideHeadlines&&(Ee+=' showRowColHeaders="0" ');let y=i.splitOption;if(typeof y>"u"&&(Re=!1,typeof i.frozenOption=="object")){const p=i.frozenOption;if(T=' state="frozen" ',p.type=="R"||p.type=="ROW"){let c;typeof p.index=="object"?c=p.index.r:c=p.index,y={startAt:{b:"A"+(c+1)},type:"H",split:c}}else if(p.type=="C"||p.type=="COLUMN"){let c;typeof p.index=="object"?c=p.index.c:c=p.index,c>l.length-1&&(l=Ke(l,c)),y={type:"V",startAt:{r:l[c]+1},split:c}}else if(p.type=="B"||p.type=="BOTH"){let c="",_;typeof p.index=="number"?(_=p.index,c=l[p.index]+(p.index+1)):(_={y:p.index.r,x:p.index.c},c=l[p.index.c]+(p.index.r+1)),y={startAt:{two:c},type:"B",split:_}}}if(y)if(y.type=="H"||y.type=="HORIZONTAL"){let p;y.startAt&&(p=y.startAt.b,y.startAt.t&&(Ee+=' topLeftCell="'+y.startAt.t+'"')),p||(p="A1"),Te='"}else if(y.type=="V"||y.type=="VERTICAL"){let p;y.startAt&&(p=y.startAt.r,y.startAt.l&&(Ee+=' topLeftCell="'+y.startAt.l+'"')),p||(p="A1"),Te='"}else{let p;y.startAt&&(p=y.startAt.two,y.startAt.one&&(Ee+=' topLeftCell="'+y.startAt.one+'"')),p||(p="A1"),Te='"}}if(Re&&(Ie="pageLayout"),a.checkbox){Ue=!0;const T=ye.checkbox;a.checkbox.forEach((i,y)=>{let p=T;if(i.link){let O=_e(i.link,l);p=p.replace("**fmlaLink**",'fmlaLink="$'+l[O.col]+"$"+(O.row+1)+'"')}else p=p.replace("**fmlaLink**","");i.mixed?p=p.replace("**value**",'checked="Mixed"'):i.checked?p=p.replace("**value**",'checked="Checked"'):p=p.replace("**value**",""),i.threeD&&p.replace('noThreeD="1"',""),ae.push(p),ve++;let c=w+""+ve++;const _="_x0000_s"+c;pt+=we.checkbox.replace("***id***",_).replace("***text***",i.text);let F=i.startStr,A=i.endStr,h={start:{col:0,row:0},end:{col:1,row:1}};if(i.col&&i.row&&(h={start:{col:i.col,row:i.row-1},end:{col:i.col,row:i.row}}),typeof F=="string"&&F.length>=2){let O=_e(F,l);h.start={...O},h.end={col:O.col+1,row:O.row+1}}if(typeof A=="string"&&A.length>=2){let O=_e(A,l);O.row+=1,O.col+=1,h.end={...O}}ut+=''+h.start.col+"19050"+h.start.row+"19050"+h.end.col+"819150"+h.end.row+"0",ht+='',dt+=''+h.start.col+"19050"+h.start.row+"19050"+h.end.col+"819150"+h.end.row+'0'+i.text+""})}let Xe;if(a.backgroundImage){v==null&&(v=f==null?void 0:f.folder("media"));const T=a.backgroundImage;Xe=new Promise(async(i,y)=>{let p=T.lastIndexOf("."),c;p>0?(c=T.substring(p+1).toLowerCase(),c.length>4&&(c.indexOf("gif")>=0?c="gif":c.indexOf("jpg")>=0?c="jpg":c.indexOf("jpeg")>=0?c="jpeg":c="png")):c="png";const _=X++,F="image"+_+"."+c,A=await _t(T,F,o,e.fetch);A||y("image not load"),Ce.push(c),i({name:F,type:c,image:A,ref:_})})}let Qe;if(a.images&&(v==null&&(v=f==null?void 0:f.folder("media")),Qe=Promise.all([...a.images.map(async(T,i)=>{let y=T.url.lastIndexOf("."),p;y>0?(p=T.url.substring(y+1).toLowerCase(),p.length>4&&(p.indexOf("gif")>=0?p="gif":p.indexOf("jpg")>=0?p="jpg":p.indexOf("jpeg")>=0?p="jpeg":p="png")):p="png",Ce.push(p);const c="image"+X+++"."+p;return{type:p,image:await _t(T.url,c,o,e.fetch),obj:T,i,name:c}})])),Array.isArray(a.headers)&&a.headers.length){const T=a.headers.length;let i="";if(a.title){const c=a.title,_=c.comment,F=c.shiftTop&&c.shiftTop>=0?c.shiftTop:0,A=a.shiftLeft&&a.shiftLeft>=0?a.shiftLeft:0,h=c.shiftLeft&&c.shiftLeft+A>=0?c.shiftLeft+A:A,O=c.consommeRow?c.consommeRow-1:1,le=c.consommeCol?c.consommeCol:T,V=O==0&&typeof c.height=="number"?' ht="'+c.height+'" customHeight="1" ':"",R=c.styleId?c.styleId:"titleStyle",I=l[h]+""+(k+F);if(xe.push(I+":"+l[h+le-1]+(k+O+F)),typeof _<"u"){Pe=!0;const Q=nt(_,N.commentSyntax.value,d);let fe=pe.length;if(Q.hasAuthor&&typeof Q.author<"u"){let ee=Q.author.toString();const re=pe.indexOf(ee);re<0?pe.push(ee):fe=re}He.push({row:k+F-1,col:h}),Le+=lt(I,Q.commentStr,Q.commentStyle,fe)}typeof c.text=="string"&&(x[k+F]={startTag:'',details:''+B+"",endTag:""},i+='',i+=''+B+"",i+="",B++,L[c.text]=c.text,c.multiStyleValue&&Array.isArray(c.multiStyleValue)?P+=at(c.multiStyleValue,N.commentSyntax.value,R):P+=""+$e(c.text)+""),k+=F+O+1}let y=a.headerStyleKey?a.headerStyleKey:null,p=0;if(typeof a.shiftLeft=="number"&&a.shiftLeft>=0&&(p=a.shiftLeft),se&&(H+='',de||(de=f==null?void 0:f.folder("tables"))),Y.start=l[p]+""+k,Y.end=l[p+a.headers.length-1]+""+(k+a.data.length),a.headers.forEach((c,_)=>{if(se&&(H+=''),p&&(_+=p),c.formula&&Ge.push(_),c.conditionalFormatting&&Ze.push(_),yt.push(c.label),a.mergeRowDataCondition&&typeof a.mergeRowDataCondition=="function"&&a.mergeRowDataCondition(c,null,_,!0)===!0&&(ke[l[_]]={inProgress:!0,start:k}),a.styleCellCondition&&typeof a.styleCellCondition=="function"&&(y=a.styleCellCondition(c,c,k,_,!0,S)||y),c.size&&c.size>0&&(W+=''),a.withoutHeader)return;const F=l[_]+""+k;if(typeof a.commentCondition=="function"){const h=a.commentCondition(c,null,c.label,k,_,!0);(typeof h=="string"||typeof h=="object"&&h!=null)&&(c.comment=h)}if(c.comment){Pe=!0;const h=nt(c.comment,N.commentSyntax.value,d);let O=pe.length;if(h.hasAuthor&&typeof h.author<"u"){let le=h.author.toString();const V=pe.indexOf(le);V<0?pe.push(le):O=V}He.push({row:k-1,col:_}),Le+=lt(F,h.commentStr,h.commentStyle,O)}const A=ue&&ue[F];if(A){const h=rt(F,A,b,e.styles);h.needCalcChain&&(ge=!0,ie+=h.chainCell),C+=h.cell,delete ue[F]}else{if(C+=''+B+"",typeof a.multiStyleCondition=="function"){const h=a.multiStyleCondition(c,null,c.label,k,_,!0);h&&(c.multiStyleValue=h)}c.multiStyleValue&&Array.isArray(c.multiStyleValue)?P+=at(c.multiStyleValue,N.commentSyntax.value,y||""):P+=""+$e(c.text)+"",L[c.text]=c.text,B++}}),se&&(H+=""),a.withoutHeader)C+=i;else{const c='_+" "+F+'="'+a.headerRowOption[F]+'" '," "):"")+">";x[k]={startTag:c,endTag:"",details:C},C=i+c+C+"",k++}if(Array.isArray(a.data)){const c=a.mapSheetDataOption&&a.mapSheetDataOption.outlineLevel?a.mapSheetDataOption.outlineLevel:"outlineLevel",_=a.mapSheetDataOption&&a.mapSheetDataOption.hidden?a.mapSheetDataOption.hidden:"hidden",F=a.mapSheetDataOption&&a.mapSheetDataOption.height?a.mapSheetDataOption.height:"height",A=a.data.length;a.data.forEach((h,O)=>{if(h.mergeType)for(let I=0;I
"); + const H = x.border; + let k = ""; + if (typeof H == "object" && ((H.left || H.full) && (k += ''), (H.right || H.full) && (k += ''), (H.top || H.full) && (k += ''), (H.bottom || H.full) && (k += ''), Y.borderIndex = w.border.count, w.border.count++, w.border.value += "" + k + ""), x.format) { + const C = r[x.format]; + C && (Y.formatIndex = C.key, "value" in C && (w.format.count++, w.format.value += C.value)); + } + return w.cell.value = w.cell.value + ' 0 ? ' applyBorder="1" ' : "") + (Y.fillIndex > 0 ? ' applyFill="1" ' : "") + (Y.fontIndex >= 0 ? ' applyFont="1" ' : "") + (Y.formatIndex > 0 ? ' applyNumberFormat="1" ' : "") + se, e.styles[a].index = w.cell.count, w.cell.count++, w; + }, + { + conditionalFormatting: { + count: G ? 1 : 0, + value: ' ' + }, + commentSyntax: { + value: {} + }, + format: { + count: 0, + value: "" + }, + border: { + count: 1, + value: "" + }, + fill: { + count: 2, + value: "" + }, + font: { + count: 2, + value: "" + }, + cell: { + count: 2, + value: "" + } + } + ); + f == null || f.file("styles.xml", Gt(N, G)); + let oe = '', P = "", B = 0, X = "", K = "", L = {}; + const E = {}; + let $ = "", q = 4, U = !1, M = -1, Ce = [], J = 1; + const ye = { + checkbox: ` +` + }; + let ve = 1024; + const we = { + checkbox: ` + + + +
***text***
+
+ + + + 0, 2, 0, 2, 0, 86, 1, 0 + False + False + Center + + +
` + }, Se = { + checkbox: ` + + + + ` + }; + let ae = [], ie = "", ge = !1, de = null; + for (let w = 0; w < s; w++) { + const a = e.sheet[w], b = w + 1; + let x = {}, Y = { + start: "", + end: "" + }; + const se = a.asTable; + let H = "", k = a.shiftTop && a.shiftTop >= 0 ? a.shiftTop + 1 : 1, C = "", W = "", ce = "", Te = "", Ee = "", _e = "", ze = !1, dt = "", pt = "", ht = "", ut = "", xe = Object.assign([], a.merges), ue = Object.assign({}, a.formula), Ue = Object.assign( + [], + a.conditionalFormatting + ), Ie = !1, pe = [], Le = "", He = [], yt = [], We = [], Ge = [], ke = {}, Pe = "", je = !1, Ze = ""; + if (a.rtl && (Ee += ' rightToLeft="1" '), a.pageBreak) { + const T = a.pageBreak; + if (T.row && Array.isArray(T.row)) { + _e = "pageBreakPreview"; + const i = T.row.length; + Ze += '' + T.row.reduce( + (y, p) => y + '', + "" + ) + ""; + } + if (T.column && Array.isArray(T.column)) { + _e = "pageBreakPreview"; + const i = T.column.length; + Ze += '' + T.column.reduce( + (y, p) => y + '', + "" + ) + ""; + } + } + let gt = ""; + if (a.pageOption) { + const T = a.pageOption; + if (T.isPortrait && (je = !0), T.margin) { + const F = T.margin; + let A = { + left: 0.7, + right: 0.7, + top: 0.75, + bottom: 0.75, + header: 0.3, + footer: 0.3 + }; + Object.keys(A).forEach((h) => { + typeof F[h] == "number" && (A[h] = F[h]); + }), gt = ''; + } + let i = "", y = "", p = "", c = ""; + if (["header", "footer"].forEach((F) => { + const A = F.charAt(0).toUpperCase() + F.substring(1); + if (T[F]) { + const h = T[F]; + typeof h == "object" && Object.keys(h).forEach((O) => { + i.indexOf(O) < 0 && (i += O); + const le = h[O]; + let V = ""; + if (Object.keys(le).reduce((R, I) => (I == "l" ? R.splice(0, 0, I) : I == "c" ? R.splice(1, 0, I) : I == "r" && R.splice(2, 0, I), R), []).forEach((R) => { + const I = le[R]; + V += "&" + R.toUpperCase(), I.styleId && z[I.styleId] && (V += z[I.styleId]), I.text && (V += I.text); + }), V = "<" + O + A + ">" + V + "", O == "odd") + y += V; + else if (O == "even") + p += V; + else if (O == "first") + c += V; + else + throw "type error"; + }); + } + }), Pe = y + p + c, Pe.length > 0) { + je = !0; + const F = i.length == 7 || i.length == 12 ? ' differentOddEven="1"' : "", A = i.indexOf("first") >= 0 ? ' differentFirst="1"' : ""; + Pe = "" + Pe + ""; + } + } + if (a.viewOption) { + let T = ""; + const i = a.viewOption; + i.type && (_e = i.type), i.hideRuler && (Ee += ' showRuler="0" '), i.hideGrid && (Ee += ' showGridLines="0" '), i.hideHeadlines && (Ee += ' showRowColHeaders="0" '); + let y = i.splitOption; + if (typeof y > "u" && (je = !1, typeof i.frozenOption == "object")) { + const p = i.frozenOption; + if (T = ' state="frozen" ', p.type == "R" || p.type == "ROW") { + let c; + typeof p.index == "object" ? c = p.index.r : c = p.index, y = { + startAt: { + b: "A" + (c + 1) + }, + type: "H", + split: c + }; + } else if (p.type == "C" || p.type == "COLUMN") { + let c; + typeof p.index == "object" ? c = p.index.c : c = p.index, c > l.length - 1 && (l = Ke(l, c)), y = { + type: "V", + startAt: { + r: l[c] + 1 + }, + split: c + }; + } else if (p.type == "B" || p.type == "BOTH") { + let c = "", _; + typeof p.index == "number" ? (_ = p.index, c = l[p.index] + (p.index + 1)) : (_ = { + y: p.index.r, + x: p.index.c + }, c = l[p.index.c] + (p.index.r + 1)), y = { + startAt: { + two: c + }, + type: "B", + split: _ + }; + } + } + if (y) + if (y.type == "H" || y.type == "HORIZONTAL") { + let p; + y.startAt && (p = y.startAt.b, y.startAt.t && (Ee += ' topLeftCell="' + y.startAt.t + '"')), p || (p = "A1"), Te = '"; + } else if (y.type == "V" || y.type == "VERTICAL") { + let p; + y.startAt && (p = y.startAt.r, y.startAt.l && (Ee += ' topLeftCell="' + y.startAt.l + '"')), p || (p = "A1"), Te = '"; + } else { + let p; + y.startAt && (p = y.startAt.two, y.startAt.one && (Ee += ' topLeftCell="' + y.startAt.one + '"')), p || (p = "A1"), Te = '"; + } + } + if (je && (_e = "pageLayout"), a.checkbox) { + ze = !0; + const T = ye.checkbox; + a.checkbox.forEach((i, y) => { + let p = T; + if (i.link) { + let O = Re(i.link, l); + p = p.replace( + "**fmlaLink**", + 'fmlaLink="$' + l[O.col] + "$" + (O.row + 1) + '"' + ); + } else + p = p.replace("**fmlaLink**", ""); + i.mixed ? p = p.replace("**value**", 'checked="Mixed"') : i.checked ? p = p.replace("**value**", 'checked="Checked"') : p = p.replace("**value**", ""), i.threeD && p.replace('noThreeD="1"', ""), ae.push(p), ve++; + let c = w + "" + ve++; + const _ = "_x0000_s" + c; + pt += we.checkbox.replace("***id***", _).replace("***text***", i.text); + let F = i.startStr, A = i.endStr, h = { + start: { + col: 0, + row: 0 + }, + end: { + col: 1, + row: 1 + } + }; + if (i.col && i.row && (h = { + start: { + col: i.col, + row: i.row - 1 + }, + end: { + col: i.col, + row: i.row + } + }), typeof F == "string" && F.length >= 2) { + let O = Re(F, l); + h.start = { + ...O + }, h.end = { + col: O.col + 1, + row: O.row + 1 + }; + } + if (typeof A == "string" && A.length >= 2) { + let O = Re(A, l); + O.row += 1, O.col += 1, h.end = { + ...O + }; + } + ut += '' + h.start.col + "19050" + h.start.row + "19050" + h.end.col + "819150" + h.end.row + "0", ht += '', dt += '' + h.start.col + "19050" + h.start.row + "19050" + h.end.col + "819150" + h.end.row + '0' + i.text + ""; + }); + } + let Xe; + if (a.backgroundImage) { + v == null && (v = f == null ? void 0 : f.folder("media")); + const T = a.backgroundImage; + Xe = new Promise(async (i, y) => { + let p = T.lastIndexOf("."), c; + p > 0 ? (c = T.substring(p + 1).toLowerCase(), c.length > 4 && (c.indexOf("gif") >= 0 ? c = "gif" : c.indexOf("jpg") >= 0 ? c = "jpg" : c.indexOf("jpeg") >= 0 ? c = "jpeg" : c = "png")) : c = "png"; + const _ = J++, F = "image" + _ + "." + c, A = await _t(T, F, o, e.fetch); + A || y("image not load"), Ce.push(c), i({ + name: F, + type: c, + image: A, + ref: _ + }); + }); + } + let Je; + if (a.images && (v == null && (v = f == null ? void 0 : f.folder("media")), Je = Promise.all([ + ...a.images.map(async (T, i) => { + let y = T.url.lastIndexOf("."), p; + y > 0 ? (p = T.url.substring(y + 1).toLowerCase(), p.length > 4 && (p.indexOf("gif") >= 0 ? p = "gif" : p.indexOf("jpg") >= 0 ? p = "jpg" : p.indexOf("jpeg") >= 0 ? p = "jpeg" : p = "png")) : p = "png", Ce.push(p); + const c = "image" + J++ + "." + p; + return { + type: p, + image: await _t(T.url, c, o, e.fetch), + obj: T, + i, + name: c + }; + }) + ])), Array.isArray(a.headers) && a.headers.length) { + const T = a.headers.length; + let i = ""; + if (a.title) { + const c = a.title, _ = c.comment, F = c.shiftTop && c.shiftTop >= 0 ? c.shiftTop : 0, A = a.shiftLeft && a.shiftLeft >= 0 ? a.shiftLeft : 0, h = c.shiftLeft && c.shiftLeft + A >= 0 ? c.shiftLeft + A : A, O = c.consommeRow ? c.consommeRow - 1 : 1, le = c.consommeCol ? c.consommeCol : T, V = O == 0 && typeof c.height == "number" ? ' ht="' + c.height + '" customHeight="1" ' : "", R = c.styleId ? c.styleId : "titleStyle", I = l[h] + "" + (k + F); + if (xe.push( + I + ":" + l[h + le - 1] + (k + O + F) + ), typeof _ < "u") { + Ie = !0; + const Q = rt( + _, + N.commentSyntax.value, + d + ); + let fe = pe.length; + if (Q.hasAuthor && typeof Q.author < "u") { + let ee = Q.author.toString(); + const re = pe.indexOf(ee); + re < 0 ? pe.push(ee) : fe = re; + } + He.push({ + row: k + F - 1, + col: h + }), Le += nt( + I, + Q.commentStr, + Q.commentStyle, + fe + ); + } + typeof c.text == "string" && (x[k + F] = { + startTag: '', + details: '' + B + "", + endTag: "" + }, i += '', i += '' + B + "", i += "", B++, L[c.text] = c.text, c.multiStyleValue && Array.isArray(c.multiStyleValue) ? P += lt( + c.multiStyleValue, + N.commentSyntax.value, + R + ) : P += "" + $e(c.text) + ""), k += F + O + 1; + } + let y = a.headerStyleKey ? a.headerStyleKey : null, p = 0; + if (typeof a.shiftLeft == "number" && a.shiftLeft >= 0 && (p = a.shiftLeft), se && (H += '', de || (de = f == null ? void 0 : f.folder("tables"))), Y.start = l[p] + "" + k, Y.end = l[p + a.headers.length - 1] + "" + (k + a.data.length), a.headers.forEach((c, _) => { + if (se && (H += ''), p && (_ += p), c.formula && We.push(_), c.conditionalFormatting && Ge.push(_), yt.push(c.label), a.mergeRowDataCondition && typeof a.mergeRowDataCondition == "function" && a.mergeRowDataCondition( + c, + null, + _, + !0 + ) === !0 && (ke[l[_]] = { + inProgress: !0, + start: k + }), a.styleCellCondition && typeof a.styleCellCondition == "function" && (y = a.styleCellCondition( + c, + c, + k, + _, + !0, + S + ) || y), c.size && c.size > 0 && (W += ''), a.withoutHeader) + return; + const F = l[_] + "" + k; + if (typeof a.commentCondition == "function") { + const h = a.commentCondition( + c, + null, + c.label, + k, + _, + !0 + ); + (typeof h == "string" || typeof h == "object" && h != null) && (c.comment = h); + } + if (c.comment) { + Ie = !0; + const h = rt( + c.comment, + N.commentSyntax.value, + d + ); + let O = pe.length; + if (h.hasAuthor && typeof h.author < "u") { + let le = h.author.toString(); + const V = pe.indexOf(le); + V < 0 ? pe.push(le) : O = V; + } + He.push({ + row: k - 1, + col: _ + }), Le += nt( + F, + h.commentStr, + h.commentStyle, + O + ); + } + const A = ue && ue[F]; + if (A) { + const h = ot( + F, + A, + b, + e.styles + ); + h.needCalcChain && (ge = !0, ie += h.chainCell), C += h.cell, delete ue[F]; + } else { + if (C += '' + B + "", typeof a.multiStyleCondition == "function") { + const h = a.multiStyleCondition( + c, + null, + c.label, + k, + _, + !0 + ); + h && (c.multiStyleValue = h); + } + c.multiStyleValue && Array.isArray(c.multiStyleValue) ? P += lt( + c.multiStyleValue, + N.commentSyntax.value, + y || "" + ) : P += "" + $e(c.text) + "", L[c.text] = c.text, B++; + } + }), se && (H += ""), a.withoutHeader) + C += i; + else { + const c = ' _ + " " + F + '="' + a.headerRowOption[F] + '" ', " ") : "") + ">"; + x[k] = { + startTag: c, + endTag: "", + details: C + }, C = i + c + C + "", k++; + } + if (Array.isArray(a.data)) { + const c = a.mapSheetDataOption && a.mapSheetDataOption.outlineLevel ? a.mapSheetDataOption.outlineLevel : "outlineLevel", _ = a.mapSheetDataOption && a.mapSheetDataOption.hidden ? a.mapSheetDataOption.hidden : "hidden", F = a.mapSheetDataOption && a.mapSheetDataOption.height ? a.mapSheetDataOption.height : "height", A = a.data.length; + a.data.forEach((h, O) => { + if (h.mergeType) + for (let I = 0; I < h.mergeType.length; I++) { + const Q = h.mergeType[I], fe = h.mergeStart[I], ee = h.mergeValue[w]; + let re = ""; + Q == "both" ? re = l[fe] + "" + k + ":" + l[fe + ee[1]] + (k + ee[0]) : Q == "col" ? re = l[fe] + "" + k + ":" + l[fe + ee[0]] + k : re = l[fe] + "" + k + ":" + l[fe] + (k + ee[0]), xe.push(re); + } + const le = h.rowStyle, V = '", + details: R + }, k++, C += ""; + }), a.sortAndFilter && (a.sortAndFilter.mode == "all" ? ce += '' : typeof a.sortAndFilter.ref == "string" && a.sortAndFilter.ref.length > 0 && (ce += '')); + } + if (We.length > 0 && We.forEach((c) => { + const _ = a.shiftLeft ? a.shiftLeft : 0, F = a.headers[c - _], A = l[c]; + ue[A + "" + k] = { + start: a.withoutHeader ? A + "1" : A + "2", + end: A + "" + (k - 1), + type: F.formula.type, + ...F.formula.styleId ? { styleId: F.formula.styleId } : {} + }; + }), Ge.length > 0 && Ge.forEach((c) => { + const _ = a.headers[c]; + _.conditionalFormatting && Ue.push({ + ..._.conditionalFormatting, + start: a.withoutHeader ? l[c] + "1" : l[c] + "2", + end: l[c] + "" + (k - 1) + }); + }), ue) { + const c = Object.keys(ue).sort( + (_, F) => _ > F ? 1 : -1 + ); + if (c.length) { + let _ = {}; + c.forEach((F) => { + const A = ot( + F, + ue[F], + b, + e.styles + ); + A.needCalcChain && (ge = !0, ie += A.chainCell), _[A.row] ? _[A.row] += A.cell : _[A.row] = A.cell; + }), Object.keys(_).forEach((F) => { + const A = F, h = _[A]; + let O = x[A]; + if (O) { + const le = O.startTag + O.details + h + O.endTag; + let V = new RegExp(O.startTag + "[\\n\\s\\S]*?"); + C = C.replace(V, le); + } else + C += '' + h + "", x[A] = { + startTag: '', + endTag: "", + details: h + }; + }); + } + } + } + w > 0 && (oe += ''); + const xt = a.name ? a.name : "sheet" + (w + 1), qt = a.state ? a.state : "visible"; + X += '', K += '', $ += "" + ("sheet" + (w + 1)) + "", a.selected && (U = !0, M = w); + const bt = a.sortAndFilter ? 'filterMode="1"' : ""; + let Ct = -1; + Xe && await Xe.then((T) => { + let i = T; + Ct = i.ref, v == null || v.file(i.name, i.image); + }); + let Ne = !1, Qe = "", vt = ""; + Je && (Ne = !0, await Je.then((T) => { + let i = ""; + T.forEach((y, p) => { + const c = p + 1; + let _ = y.image; + const F = y.name; + let A = y.obj.from, h = y.obj.to, O = y.obj.margin; + y.type; + let le = y.obj.type, V = y.obj.extent; + typeof V > "u" && (V = { + cx: 2e5, + cy: 2e5 + }); + let R = { + start: { + col: 0, + row: 0, + mL: 0, + mT: 0 + }, + end: { + col: 1, + row: 1, + mR: 0, + mB: 0 + } + }; + if (typeof A == "string" && A.length >= 2) { + let I = Re(A, l); + R.start = { + ...I + }, R.end = { + col: I.col + 1, + row: I.row + 1 + }; + } + if (typeof h == "string" && h.length >= 2) { + let I = Re(h, l); + I.row += 1, I.col += 1, R.end = { + ...I + }; + } + R.end.mR = 0, R.end.mB = 0, R.start.mL = 0, R.start.mT = 0, O && ((O.all || O.right) && (R.end.mR = O.all || O.right), (O.all || O.bottom) && (R.end.mB = O.all || O.bottom), (O.all || O.left) && (R.start.mL = O.all || O.left), (O.all || O.top) && (R.start.mT = O.all || O.top)), le == "one" ? Qe += "" + R.start.col + "" + R.start.mT + "" + R.start.row + "" + R.start.mL + '' : Qe += '' + R.start.col + "" + R.start.mT + "" + R.start.row + "" + R.start.mL + "" + R.end.col + "" + R.end.mB + "" + R.end.row + "" + R.end.mR + '', v == null || v.file(F, _), i += ''; + }), vt = ` +` + i + ""; + })), xe = [...new Set(xe)]; + let wt = "", Ae = 1; + Ue.length > 0 && (wt = Ue.reduce((T, i) => { + if (i.type == "cells") + return i.operator == "ct" ? T + 'NOT(ISERROR(SEARCH("' + i.value + '",' + i.start + ")))" : typeof i.operator > "u" || typeof n[i.operator] > "u" ? T : T + '' + (Array.isArray(i.value) ? i.value.reduce((y, p) => y + "" + p.value + "", "") : "" + i.value + "") + ""; + if (i.type == "top") + return T + '"; + if (i.type == "iconSet") { + let y = ""; + return typeof i.operator > "u" ? T : (i.operator.indexOf("5") == 0 ? y = '' : i.operator.indexOf("4") == 0 ? y = '' : y = '', T + '' + y + ""); + } else return i.type == "colorScale" ? T + '' + (i.operator == "percentile" ? '' : "") + '' + (i.colors && Array.isArray(i.colors) ? i.colors.reduce((y, p) => y + '', "") : '') + "" : i.type == "dataBar" ? T + '' + (i.colors && Array.isArray(i.colors) ? i.colors.reduce((y, p) => y + '', "") : '') + "" : T; + }, "")), (ze || Ie || Ne) && D == null && (D = f == null ? void 0 : f.folder("drawings")), Ne && j == null && (j = D == null ? void 0 : D.folder("_rels")), E["sheet" + (w + 1)] = { + indexId: q + 1, + key: "sheet" + (w + 1), + sheetName: xt, + sheetDataTableColumns: H, + backgroundImageRef: Ct, + sheetDimensions: Y, + asTable: se || !1, + sheetDataString: C, + sheetDropDown: ro(a.dropDowns), + sheetBreakLine: Ze, + viewType: _e, + hasComment: Ie, + drawersContent: Qe, + cFDataString: wt, + sheetMargin: gt, + sheetHeaderFooter: Pe, + isPortrait: je, + drawersRels: vt, + hasImages: Ne, + hasCheckbox: ze, + formRel: ht, + checkboxDrawingContent: dt, + checkboxForm: ae, + checkboxSheetContent: ut, + checkboxShape: pt, + commentString: Le, + commentAuthor: pe, + shapeCommentRowCol: He, + splitOption: Te, + sheetViewProperties: Ee, + sheetSizeString: W.length > 0 ? "" + W + "" : "", + protectionOption: a.protectionOption ? Object.keys(a.protectionOption).reduce((T, i) => T + " " + i + '="' + a.protectionOption[i] + '" ', "" : "", + merges: xe.length > 0 ? xe.reduce((T, i) => T + ' ', '') + " " : "", + selectedView: !!a.selected, + sheetSortFilter: ce, + tabColor: a.tabColor ? '' : "' + }, q++; + } + ge && (q++, K += '', f == null || f.file( + "calcChain.xml", + ` +` + ie + "" + )); + let Mt = Object.keys(E), qe = m.folder("_rels"); + qe == null || qe.file( + ".rels", + ` + ` + ); + let Oe = m.folder("docProps"); + Oe == null || Oe.file( + "core.xml", + ` +` + (e.creator ? "" + e.creator + "" : "") + (e.created ? '' + e.created + "" : "") + (e.modified ? '' + e.modified + "" : "") + "" + ), Oe == null || Oe.file("app.xml", Xt(s, $)), f == null || f.file( + "workbook.xml", + ` + ` + (U ? '' : "") + " " + X + " " + ), f == null || f.file( + "sharedStrings.xml", + ` + ' + P + "" + ); + let Ye = f == null ? void 0 : f.folder("_rels"); + Ye == null || Ye.file( + "workbook.xml.rels", + ` + ` + K + " " + ); + let Ve = f == null ? void 0 : f.folder("theme"); + Ve == null || Ve.file( + "theme1.xml", + ` +` + ); + let Fe = f == null ? void 0 : f.folder("worksheets"), ft = [], mt = [], De = []; + if (Mt.forEach((w, a) => { + const b = E[w]; + let x = "", Y = { + form: !1, + drawing: !1, + vmlDrwing: !1, + comment: !1, + table: !1, + sheetDrawingsPushed: !1 + }; + const se = b.sheetDataTableColumns; + if (se.length > 0) { + mt.push("table" + (a + 1) + ".xml"); + const C = b.asTable, W = b.sheetDimensions; + de == null || de.file( + "table" + (a + 1) + ".xml", + ` +' + se + '
' + ), x += ''; + } + const H = "drawing" + (De.length + 1) + ".xml"; + if (b.hasImages && (De.push(H), Y.sheetDrawingsPushed = !0, j == null || j.file( + H + ".rels", + b.drawersRels.toString() + ), Y.drawing = !0, x += ''), b.hasCheckbox && (Y.sheetDrawingsPushed || De.push(H), x += '' + (Y.drawing ? "" : ''), Y.drawing = !0, Y.vmlDrwing = !0, x += b.formRel), (b.hasCheckbox || b.hasImages) && (D == null || D.file( + H, + ` +` + (b.hasImages ? b.drawersContent : "") + (b.hasCheckbox ? b.checkboxDrawingContent : "") + "" + )), b.hasComment) { + ft.push(a + 1); + let C = b.commentAuthor; + f == null || f.file( + "comments" + (a + 1) + ".xml", + ` +` + (Array.isArray(C) && C.length > 0 ? C.reduce( + (W, ce) => W + "" + ce + "", + "" + ) : "") + "" + b.commentString + "" + ), x += '' + (Y.vmlDrwing ? "" : ''); + } + if ((b.hasComment || b.hasCheckbox) && (D == null || D.file( + "vmlDrawing" + (a + 1) + ".vml", + '' + (b.hasCheckbox ? Se.checkbox + b.checkboxShape : "") + (b.hasComment ? ' ' + b.shapeCommentRowCol.reduce((C, W) => C + `", "") : "") + "" + )), b.backgroundImageRef > 0 && (x += ''), b.hasImages || b.hasComment || b.hasCheckbox || se.length > 0 || b.backgroundImageRef > 0) { + const C = Fe == null ? void 0 : Fe.folder("_rels"); + C == null || C.file( + "sheet" + (a + 1) + ".xml.rels", + ` + ` + x + "" + ); + } + let k = ""; + b.selectedView || b.splitOption ? k = ' 0 ? ' view="' + b.viewType + '"' : "") + ' workbookViewId="0">' + b.splitOption + (b.selectedView ? '' : "") + "" : k = ' 0 ? ' view="' + b.viewType + '"' : "") + "/>", Fe == null || Fe.file( + b.key + ".xml", + ` +` + b.tabColor + k + '' + b.sheetSizeString + "" + b.sheetDataString + "" + b.sheetDropDown + b.protectionOption + b.sheetSortFilter + b.merges + b.cFDataString + (b.hasImages || b.hasCheckbox ? '' : "") + (b.hasComment || b.hasCheckbox ? '' : "") + (b.hasCheckbox ? '' + b.checkboxSheetContent + "" : "") + b.sheetMargin + (b.isPortrait || b.sheetBreakLine.length > 0 ? '' : "") + b.sheetBreakLine + b.sheetHeaderFooter + (b.backgroundImageRef > 0 ? '' : "") + (se.length > 0 ? ' ' : "") + "" + ); + }), ae.length > 0) { + let w = f == null ? void 0 : f.folder("ctrlProps"); + ae.forEach((a, b) => { + w == null || w.file("ctrlProp" + (b + 1) + ".xml", a); + }); + } + if (m.file( + "[Content_Types].xml", + Zt( + oe, + ft, + [...new Set(Ce)], + De, + ae, + ge, + mt + ) + ), o) + return m.generateAsync({ + type: e.generateType ? e.generateType : "nodebuffer" + }).then((w) => w); + if (e.notSave) + return m.generateAsync({ type: "blob" }).then((w) => w.slice( + 0, + w.size, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + )); + m.generateAsync({ type: "blob" }).then(function(w) { + import("./FileSaver.min-BEH1o5YI.js").then((a) => a.F).then((a) => { + const { saveAs: b } = a; + b( + w, + (e.fileName ? e.fileName : "tableRecord") + ".xlsx" + ); + }); + }); +} +function no(e) { + const t = e.length; + let r = 0, o = {}, n = {}, l = {}; + for (let s = 0; s < t; s++) { + const f = e[s], v = f.length; + let D = {}; + for (let j = 0; j < v; j++) { + r++; + const S = f[j]; + let d; + S.sheetName ? d = S.sheetName : d = "Sheet 1", d in o || (o[d] = { + headers: [], + data: [], + labelCounter: 0, + seenAt: s + }), d in n || (n[d] = { + index: s, + value: 0 + }), d in l || (o[d].labelCounter = 0, l[d] = !0); + let G = []; + const z = o[d].headers.length; + let Z = {}, N = o[d].seenAt == s, oe = S.headers.reduce((K, L, E) => (o[d].labelCounter++, z < o[d].labelCounter && G.push({ + label: "c" + o[d].labelCounter, + text: N ? L.text : "" + }), Z["c" + o[d].labelCounter] = L.text, { + ...K, + [L.label]: "c" + o[d].labelCounter + }), {}); + if (o[d].headers.push(...G), S.spaceX) + for (let K = 0; K < S.spaceX; K++) + o[d].labelCounter++, z <= o[d].labelCounter && o[d].headers.push({ + label: "c" + o[d].labelCounter, + text: "" + }); + n[d].index + 1 == s && (D[d] = n[d].value); + let P = D[d] || 0; + P > 0 && (!o[d].headerIndex || o[d].headerIndex && o[d].headerIndex != P ? o[d].data.push(Z) : o[d].data[P] = { + ...o[d].data[P], + ...Z + }, o[d].headerIndex = P, P++); + let B = Object.keys(oe), X = S.data.length >= o[d].data.length; + if (o[d].data = S.data.reduce((K, L, E) => { + let $ = {}; + return K.length > E + P ? $ = K[E + P] : K.push($), B.forEach((q) => { + let U = oe[q]; + $[U] = L[q] ? L[q] : ""; + }), $.tableIndex = r, $.tableStringIndex = E + "," + j, K[E + P] = $, K; + }, o[d].data), X && S.spaceY) { + const K = o[d].headers.length; + for (let L = 0; L < S.spaceY; L++) { + let E = {}; + for (let $ = 0; $ < K; $++) { + const q = o[d].headers[$]; + E[q.label] = ""; + } + o[d].data.push(E); + } + } + n[d] = { + value: Math.max(o[d].data.length, n[d].value), + index: s + }; + } + l = {}; + } + let g = Object.keys(o), u = []; + return g.reduce( + (s, f) => { + let v = o[f]; + return s.sheet.push({ + ...v, + name: f + }), s; + }, + { sheet: u } + ); +} +function it(e) { + return /^[A-Z]+[1-9][1-9]*:[A-Z]+[1-9][1-9]*$/.test(e); +} +function st(e) { + return /^[A-Z]+[1-9][1-9]*$/.test(e); +} +const lo = { + fontFamily: { + mode: "TYPE_CHECK", + type: "string" + }, + type: { + mode: "TYPE_CHECK", + type: "string" + }, + size: { + mode: "TYPE_CHECK", + type: "number" + }, + index: { + mode: "TYPE_CHECK", + type: "number" + }, + alignment: { + mode: "TYPE_CHECK", + type: "object", + validateFunction(e, t, r, o) { + return t.rtl && t.ltr && o && console.warn("Alignment-rtl and ltr cannot be used together."), (t.readingOrder && t.ltr || t.readingOrder && t.rtl) && o && console.warn( + "Alignment-readingOrder cannot be used with rtl or ltr." + ), !0; + } + }, + border: { + mode: "TYPE_CHECK", + type: "object", + validateFunction(e, t, r, o) { + const n = ["full", "top", "left", "right", "bottom"], l = [ + "slantDashDot", + "dotted", + "thick", + "hair", + "dashDot", + "dashDotDot", + "dashed", + "thin", + "mediumDashDot", + "medium", + "double", + "mediumDashed" + ]; + return Object.keys(t).forEach((u) => { + const m = u; + if (n.indexOf(m) < 0) + throw 'border-The type of border is not valid. Valid options include "full," "top," "left," "right," and "bottom."'; + const s = t[m]; + if (!("color" in s)) + throw "border-The border must have a color."; + if (!("style" in s)) + throw "border-The border needs a style."; + if (typeof s.style == "string" && l.indexOf(s.style) < 0) + throw "border-An invalid style has been used."; + }), !0; + } + }, + format: { + mode: "TYPE_CHECK", + type: "string" + }, + bold: { + mode: "TYPE_CHECK", + type: "boolean" + }, + underline: { + mode: "TYPE_CHECK", + type: "boolean" + }, + italic: { + mode: "TYPE_CHECK", + type: "boolean" + }, + doubleUnderline: { + mode: "TYPE_CHECK", + type: "boolean" + }, + color: { + mode: "TYPE_CHECK", + type: "string" + }, + backgroundColor: { + mode: "TYPE_CHECK", + type: "string" + } +}, ao = { + notSave: { + mode: "TYPE_CHECK", + type: "boolean" + }, + creator: { + mode: "TYPE_CHECK", + type: "string", + notEmpty: !0 + }, + backend: { + mode: "TYPE_CHECK", + type: "boolean" + }, + activateConditionalFormatting: { + mode: "TYPE_CHECK", + type: "boolean" + }, + fileName: { + mode: "TYPE_CHECK", + type: "string", + notEmpty: !0 + }, + generateType: { + mode: "TYPE_CHECK", + type: "string", + isEnum: !0, + enum: ["nodebuffer", "array", "binarystring", "base64"] + }, + addDefaultTitleStyle: { + mode: "TYPE_CHECK", + type: "boolean" + }, + created: { + mode: "TYPE_CHECK", + type: "string", + notEmpty: !0 + }, + modified: { + mode: "TYPE_CHECK", + type: "string", + notEmpty: !0 + }, + numberOfColumn: { + mode: "TYPE_CHECK", + type: "number", + min: 26 + }, + createType: { + mode: "TYPE_CHECK", + type: "string" + }, + styles: { + mode: "TYPE_CHECK", + type: "object" + }, + sheet: { + mode: "TYPE_CHECK", + type: "object", + isArray: !0 + } +}, io = { + headers: { + mode: "TYPE_CHECK", + isArray: !0, + type: "object" + }, + data: { + mode: "TYPE_CHECK", + isArray: !0, + type: "object" + }, + withoutHeader: { + mode: "TYPE_CHECK", + type: "boolean" + }, + mapSheetDataOption: { + mode: "TYPE_CHECK", + type: "object", + validateFunction(e, t, r, o) { + const n = Object.keys(t), l = ["outlineLevel", "hidden", "height"]; + return n.forEach((g) => { + l.indexOf(g) < 0 && o && console.warn( + 'The Schema of mapSheetDataOption does not include the "' + g + '" property.' + ); + }), !0; + } + }, + backgroundImage: { + mode: "TYPE_CHECK", + type: "string", + notEmpty: !0 + }, + conditionalFormatting: { + mode: "TYPE_CHECK", + isArray: !0, + type: "object", + validateFunction(e, t, r, o) { + return Array.isArray(t) && t.forEach((n) => { + if (n.type == "cells") { + const l = ["lt", "gt", "between", "ct", "eq"]; + if (!n.operator || !n.start || !n.end || typeof n.value > "u") + throw { + record: n, + error: "The object is not complete; you need to fill in the values for operator, start, end and value." + }; + if (l.indexOf(n.operator) < 0) + throw { record: n, error: "The operator is not valid." }; + } else if (n.type == "top") { + const l = ["belowAverage", "aboveAverage"]; + if (!n.start || !n.end || typeof n.value > "u") + throw { + record: n, + error: "The object is not complete; you need to fill in the values for start, end and value." + }; + if (n.operator && l.indexOf(n.operator) < 0) + throw { record: n, error: "The operator is not valid." }; + } else if (n.type == "iconSet") { + if (!n.operator || !n.start || !n.end) + throw { + record: n, + error: "The object is not complete; you need to fill in the values for operator, start and end" + }; + } else if (n.type == "colorScale") { + if (!n.start || !n.end) + throw { + record: n, + error: "The object is not complete; you need to fill in the values for start and end" + }; + } else if (n.type == "dataBar") { + if (!n.start || !n.end) + throw { + record: n, + error: "The object is not complete; you need to fill in the values for start and end" + }; + } else + throw 'Property "type" is not valid.'; + }), !0; + } + }, + multiStyleCondition: { + mode: "TYPE_CHECK", + type: "function" + }, + useSplitBaseOnMatch: { + mode: "TYPE_CHECK", + type: "boolean" + }, + convertStringToNumber: { + mode: "TYPE_CHECK", + type: "boolean" + }, + images: { + mode: "TYPE_CHECK", + isArray: !0, + type: "object", + validateFunction(e, t, r, o) { + if (Array.isArray(t)) { + const n = ["one", "two"]; + t.forEach((l) => { + if (typeof l.src != "string") + throw '"src" property is required.'; + if (typeof l.from != "string" || l.from.length == 0) + throw '"from" property is required.'; + if (l.to && !st(l.to)) + throw 'value of "to" is not valid.'; + if (l.from && !st(l.from)) + throw 'value of "from" is not valid.'; + if (n.indexOf(l.type) < 0) + throw 'Type of "type" is not valid in the "images" property.'; + if (l.type == "two" && !l.to) + throw '"to" property is empty. for "two" type "to" property is required.'; + }); + } + return !0; + } + }, + formula: { + mode: "TYPE_CHECK", + type: "object" + }, + pageOption: { + mode: "TYPE_CHECK", + type: "object" + }, + name: { + mode: "TYPE_CHECK", + type: "string", + notEmpty: !0 + }, + title: { + mode: "TYPE_CHECK", + type: "object" + }, + shiftTop: { + mode: "TYPE_CHECK", + type: "number", + min: 0 + }, + shiftLeft: { + mode: "TYPE_CHECK", + type: "number" + }, + selected: { + mode: "TYPE_CHECK", + type: "boolean" + }, + tabColor: { + mode: "TYPE_CHECK", + type: "string", + notEmpty: !0 + }, + merges: { + mode: "TYPE_CHECK", + isArray: !0, + type: "object", + validateFunction(e, t, r, o) { + if (Array.isArray(t)) { + let n = []; + if (t.forEach((l) => { + it(l) || n.push( + "The " + l + ' reference is not valid in the "merges" property.' + ); + }), n.length > 0) + throw n; + } + return !0; + } + }, + headerStyleKey: { + mode: "TYPE_CHECK", + type: "string", + notEmpty: !0 + }, + mergeRowDataCondition: { + mode: "TYPE_CHECK", + type: "function" + }, + styleCellCondition: { + mode: "TYPE_CHECK", + type: "function" + }, + commentCondition: { + mode: "TYPE_CHECK", + type: "function" + }, + sortAndFilter: { + mode: "TYPE_CHECK", + type: "object", + validateFunction(e, t, r, o) { + if (typeof t == "object") { + const n = ["all", "ref"]; + if (!t.mode) + throw '"mode" is required in sortAndFilter'; + if (n.indexOf(t.mode) < 0) + throw '"mode" is not valid'; + if (t.mode == "ref") + if (t.ref) { + if (!it(t.ref)) + throw '"ref" is not valid'; + } else + throw '"ref" is must need be defined.'; + } + return !0; + } + }, + state: { + mode: "TYPE_CHECK", + type: "string", + isEnum: !0, + enum: ["hidden", "visible"] + }, + headerRowOption: { + mode: "TYPE_CHECK", + type: "object" + // Adjust according to the expected type for headerRowOption + }, + protectionOption: { + mode: "TYPE_CHECK", + type: "object", + validateFunction(e, t, r, o) { + const n = [ + "sheet", + "formatCells", + "formatColumns", + "formatRows", + "insertColumns", + "insertRows", + "insertHyperlinks", + "deleteColumns", + "deleteRows", + "sort", + "autoFilter", + "pivotTables" + ], l = ["0", "1", 0, 1]; + return Object.keys(t).forEach((u) => { + const m = t[u]; + if (n.indexOf(u) < 0) + throw '"' + u + '" is not valid.'; + if (l.indexOf(m) < 0) + throw 'value of "' + u + '" is not valid'; + }), !0; + } + }, + headerHeight: { + mode: "TYPE_CHECK", + type: "number", + min: 1 + }, + checkbox: { + mode: "TYPE_CHECK", + isArray: !0, + type: "object", + validateFunction(e, t, r, o) { + if (Array.isArray(t)) + t.forEach((n) => { + if (!n.col || !n.row) + throw '"checkbox" is not complete'; + }); + else + throw 'Type of "checkbox" property is not valid'; + return !0; + } + }, + viewOption: { + mode: "TYPE_CHECK", + type: "object", + validateFunction(e, t, r, o) { + const n = ["pageLayout", "pageBreakPreview"]; + if (t.type && n.indexOf(t.type) < 0) + throw 'Type of "type" property is not valid'; + return !0; + } + }, + rtl: { + mode: "TYPE_CHECK", + type: "boolean" + }, + pageBreak: { + mode: "TYPE_CHECK", + type: "object", + isArray: !0 + }, + asTable: { + mode: "TYPE_CHECK", + type: "object" + } +}; +function Bt(e, t = !0, r = !0) { + Object.keys(e).forEach((n) => { + const l = e[n], g = Object.keys(l); + if (l.format && !Lt[l.format]) + throw 'The "' + l.format + '" format that has been used is not defined.'; + l.underline && l.doubleUnderline, g.forEach((u) => { + let m = l[u]; + const s = lo[u]; + if (Me(m, s, u, t, r)) + return !0; + }); + }); +} +function $t(e, t = !0, r = !0) { + Array.isArray(e) || (e = [e]), e.forEach((o) => { + Object.keys(o).forEach((l) => { + const g = o[l], u = io[l]; + Me(g, u, l, t, r); + }); + }); +} +function so(e, t = !0, r = !0) { + Object.keys(e).forEach((n) => { + let l = e[n]; + const g = ao[n]; + if (Me(l, g, n, t, r)) + if (n == "sheet") + if (Array.isArray(l)) + $t(l); + else + throw "Sheet must be Array."; + else n == "styles" && Bt(l); + }); +} +function Me(e, t, r, o, n) { + if (t) { + if (typeof e != t.type) { + if (t.type == "object" || t.type == "string" || o) + throw 'The Type of The "' + r + '" is not valid'; + n && console.warn("The property type must be " + t.type); + } + if (t.isEnum && t.enum.indexOf(e) < 0) + throw 'The value of "' + r + '" must be ' + JSON.stringify(t.enum); + if (t.min && e < t.min) + throw 'The value of "' + r + '" must be higher than ' + t.min; + if (t.notEmpty && (!e || e.length <= 0)) + throw 'The value of "' + r + '" must not be empty.'; + if (t.isArray && !Array.isArray(e)) + throw 'The value of "' + r + '" should be an array.'; + return typeof t.validateFunction == "function" && t.validateFunction(r, e, o, n), !0; + } else + return n && console.warn( + 'The Schema Object does not include the "' + r + '" property.' + ), !1; +} +const co = { + checkSheetValidWithOneRef: st, + checkSheetValidWithTwoRef: it, + generalValidationCheck: Me +}, ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + exportedForTesting: co, + validateExcelTableObjectFunction: so, + validateSheetArrayFunction: $t, + validateStyleObjectFunction: Bt +}, Symbol.toStringTag, { value: "Module" })); +function It(e) { + if (typeof e > "u" || e == null) + return ""; + typeof e != "string" && (e = String(e)); + let t = e, r = !1; + return e.indexOf('"') >= 0 && (t = t.replace(/"/g, '""'), r = !0), e.indexOf(",") >= 0 && (r = !0), r && (t = '"' + t + '"'), t; +} +function fo(e) { + return e ? " " : ","; +} +function Pt(e, t) { + return e.substring(0, e.length - t) + ` +`; +} +async function Kt(e, t = !1, r = !1) { + const o = fo(r), n = r ? ".txt" : ".csv", l = o.length; + let g = []; + if (e.sheet.forEach((m) => { + let s = "", f = ""; + const v = m.headers; + let D = [], j = v.length; + for (let S = 0; S < j; S++) { + const d = v[S]; + D.push(d.label), m.withoutHeader || (f += It(d.text) + o); + } + s += Pt(f, l), j = m.data.length; + for (let S = 0; S < j; S++) { + f = ""; + const d = m.data[S]; + D.forEach((G) => { + f += It(d[G]) + o; + }), s += Pt(f, l); + } + g.push(s); + }), e.backend) + return g; + const u = await import("./FileSaver.min-BEH1o5YI.js").then((m) => m.F).then((m) => m.saveAs); + if (t) { + const m = await import("./jszip.min-D-TEDr9v.js").then((v) => v.j).then((v) => v.default); + let s = new m(); + g.forEach((v, D) => { + s.file("sheet" + (D + 1) + n, v); + }); + const f = await s.generateAsync({ type: "blob" }).then(function(v) { + return v; + }); + return u( + f, + (e.fileName ? e.fileName : "tableRecord") + ".zip" + ), "done"; + } + g.forEach((m) => { + var s = new Blob([m], { + type: "text/" + (r ? "plain" : "csv") + ";charset=utf-8" + }); + u( + s, + (e.fileName ? e.fileName : "tableRecord") + n + ); + }); +} +const jt = { + firstHeader: !0, + returnTableNodes: !1, + emptyNodeDefaultString: " ", + removeContainerChildNode: !0, + containerNodeStyle: { + display: "flex", + flexDirection: "column" + }, + tableStyle: { + borderSpacing: "0", + border: "1px solid #EEEEEEF1" + }, + cellStyle: { + width: "68px", + height: "24px", + border: "1px solid #EEEEEEF1" + }, + buttonContainerStyle: { + display: "flex" + }, + buttonStyle: { + height: "40px", + width: "80px", + display: "flex", + justifyContent: "center", + alignItems: "center", + border: "0", + background: "transparent", + cursor: "pointer" + }, + activeButtonStyle: { + background: "#EEEDEB" + } +}; +async function mo(e, t, r, o, n = !0, l = !1, g = " ", u = !0, m = { + display: "flex", + flexDirection: "column" +}, s = { + borderSpacing: "0", + border: "1px solid #EEEEEEF1" +}, f = { + width: "68px", + height: "24px", + border: "1px solid #EEEEEEF1" +}, v = { + display: "flex" +}, D = { + height: "40px", + width: "80px", + display: "flex", + justifyContent: "center", + alignItems: "center", + border: "0", + background: "transparent", + cursor: "pointer" +}, j = { + background: "#EEEDEB" +}) { + let S = await import("./read-utils-YAGe6NNW.js").then( + async (E) => await E.extractExcelData(e, !1, o) + ), d = null; + if (t ? d = document.querySelector(t) : r && (d = r), d == null && !l) + throw "Container Node not found"; + const G = Object.keys(m), z = Object.keys(s), Z = Object.keys(f), N = Object.keys(v), oe = Object.keys(D), P = Object.keys(j); + let B = document.createElement("div"); + N.forEach((E) => { + B.style[E] = v[E]; + }), l || (u && d != null && (d.innerText = ""), G.forEach((E) => { + d.style[E] = m[E]; + }), d.appendChild(B)); + let X = [], K = !1, L = 0; + do { + L++; + const E = S.sheetName.next(); + if (!E.value) + break; + const $ = document.createElement("div"); + if ($.style.display = "none", !l) { + const J = document.createElement("button"); + oe.forEach((ye) => { + J.style[ye] = D[ye]; + }), J.addEventListener("click", (ye) => { + const ve = J.getAttribute("data-sheet"), we = d.querySelector( + 'div[data-sheet="' + ve + '"]' + ); + if (we) { + P.forEach((ie) => { + J.style[ie] = j[ie]; + }); + const Se = d.querySelector( + "[data-sheet-button-activate]" + ); + let ae = d.querySelector("[data-sheet-activate]"); + we.setAttribute("data-sheet-activate", "1"), we.style.display = "flex", J.setAttribute("data-sheet-button-activate", "1"), Se && (oe.forEach((ie) => { + Se.style[ie] = D[ie]; + }), Se.removeAttribute("data-sheet-button-activate")), ae && (ae.style.display = "none", ae.removeAttribute("data-sheet-activate")); + } else + console.error("Sheet content not found!! id is " + ve); + }), J.setAttribute("data-sheet", L + ""), $.setAttribute("data-sheet", L + ""), J.innerText = E.value[1] || E.value[0], B.appendChild(J), d.appendChild($); + } + let q = n ? "th" : "td"; + const U = document.createElement("table"); + z.forEach((J) => { + U.style[J] = s[J]; + }); + const M = S.data[E.value[0]] || S.data[E.value[1]], Ce = S.maxLengthOfColumn[E.value[0]] || S.maxLengthOfColumn[E.value[1]]; + if (Array.isArray(M)) { + const J = M.length; + for (let ye = 0; ye < J; ye++) { + const ve = M[ye], we = document.createElement("tr"), Se = Array.isArray(ve); + for (let ae = 0; ae <= Ce; ae++) { + let ie = g; + if (Se) { + const de = ve[ae]; + typeof de == "string" && (ie = de); + } + const ge = document.createElement(q); + Z.forEach((de) => { + ge.style[de] = f[de]; + }), ge.innerText = ie, we.appendChild(ge); + } + U.appendChild(we), q = "td"; + } + } + l ? X.push(U) : ($.appendChild(U), d == null || d.appendChild($)), K = E.done; + } while (!K); + if (l) + return X; + { + const E = d.querySelector( + 'div[data-sheet="1"]' + ); + E && (E.style.display = "flex", E.setAttribute("data-sheet-activate", "1")); + const $ = d.querySelector( + 'button[data-sheet="1"]' + ); + return $ && (P.forEach((q) => { + $.style[q] = j[q]; + }), $.setAttribute("data-sheet-button-activate", "1")), "Done"; + } +} +async function uo(e, t, r = !0, o = "property") { + let n = await import("./read-utils-YAGe6NNW.js").then( + async (u) => await u.extractExcelData(e, !1, t) + ), l = {}, g = []; + return Object.keys(n.sheetNameObject).forEach((u) => { + const m = n.sheetNameObject[u], s = n.data[m] || n.data[u], f = n.maxLengthOfColumn[m] || n.maxLengthOfColumn[u]; + for (let j = 0; j <= f; j++) + g[j] = o + (j + 1); + let v = r, D = []; + s.forEach((j) => { + let S = {}; + j.forEach((d, G) => { + typeof d == "string" && (v ? g[G] = d : S[g[G]] = d); + }), v = !1, D.push(S); + }), l = Object.assign(l, { + [m]: D + }); + }), l; +} +const yo = Ht, go = to; +function xo(e, t, r = {}) { + const o = Wt( + e, + t, + r.keepStyle, + r.rowHeightScaleFunction, + r.colWidthScaleFunction + ); + return ct(o); +} +function bo(e) { + const t = no(e); + return ct(t); +} +function Co(e, t) { + return ct(zt(e, t)); +} +function vo(e, t = !1, r) { + return import("./read-utils-YAGe6NNW.js").then( + (o) => o.extractExcelData(e, t, r) + ); +} +function wo(e, t = !1) { + return Kt(e, t, !1); +} +function To(e, t = !1) { + return Kt(e, t, !0); +} +function Eo(e, t, r, o = { ...jt }) { + return o = { + ...jt, + ...o + }, mo( + e, + t, + r, + o.fetchFunc, + o.firstHeader, + o.returnTableNodes, + o.emptyNodeDefaultString, + o.removeContainerChildNode, + o.containerNodeStyle, + o.tableStyle, + o.cellStyle, + o.buttonContainerStyle, + o.buttonStyle, + o.activeButtonStyle + ); +} +export { + yo as a, + go as b, + Qt as c, + xo as d, + vo as e, + wo as f, + Re as g, + To as h, + Eo as i, + ct as j, + uo as k, + po as r, + bo as s, + Co as t, + ho as v +}; diff --git a/dist/read-utils-CwMyWpVb.js b/dist/read-utils-CwMyWpVb.js new file mode 100644 index 0000000..c47491c --- /dev/null +++ b/dist/read-utils-CwMyWpVb.js @@ -0,0 +1 @@ +System.register("ExcelTable",["./index-BPuSW_h3.js"],function(R,B){"use strict";var b,A;return{setters:[d=>{b=d.g,A=d.c}],execute:function(){R("extractExcelData",W);function d(s){return/t="s".*?(.*?)<\/t>/,r=s.match(a);return r?r[1]:null}function M(s){const a=/(.*?)<\/v>/,r=s.match(a);return r?r[1]:null}function P(s){const a=/r="(.*?)"/,r=s.match(a);return r?r[1]:null}async function W(s,a=!1,r){let O,E=!1;typeof r=="function"?(O=r,E=!0):O=fetch;let y=[],p=new Map,C={},k=[],V={},j={},T=!1;function $(t,I){let g=0,o=[],m=I.match(//g);if(Array.isArray(m)&&m.forEach(n=>{let f=M(n);d(n)&&f&&(f=k[parseInt(f)]);const w=P(n);let i=b(w,A);typeof o[i.row]>"u"&&(o[i.row]=[]),o[i.row][i.col]=f,g=Math.max(i.col,g)}),t.indexOf("xl/worksheets/sheet")==0){let n=t.substring(14,t.lastIndexOf("."));p.has(n)&&(n=p.get(n)),V[n]=o,j[n]=g}}return await O(s).then(t=>{if(t==null||t==null)throw"response is null";return E?t:a?t.arrayBuffer():t.blob()}).then(async t=>{const g=(await B.import("./jszip.min-49JP7itW.js").then(m=>m.j)).default;let o=0;return await new Promise((m,n)=>{g.loadAsync(t).then(function(f){const w=Object.keys(f.files);o=w.length;let i=new Proxy({counter:0,isNameSet:!1},{set(e,c,u){if(c==="isNameSet")return e.isNameSet=u,!0;if(typeof u!="number")throw"value most be number";return e.counter=u,e.isNameSet&&e.counter===o&&m({data:V,sheetNameObject:C,sheetName:p.entries(),maxLengthOfColumn:j}),!0},get(e,c,u){return c==="isNameSet"?e.isNameSet:e.counter}});w.forEach(function(e){f.files[e].async("string").then(function(c){if(e.indexOf("sharedStrings")>=0){let u=c.match(//g);Array.isArray(u)&&u.forEach(S=>{let h=S.match(//g);if(Array.isArray(h)){let N=h.reduce((l,x)=>l+D(x),"");k.push(N)}}),T=!0,y.length>0&&(y.forEach(S=>{$(S.filename,S.fileData)}),y=[])}e.indexOf("sheet")>=0&&(T?$(e,c):y.push({filename:e,fileData:c})),e.indexOf("workbook")>=0&&(c.replace(/(.*[\n\s\S]*)()(.*[\n\s\S]*)/,"$2").split("{let l=N+1,x="Sheet "+l;h.indexOf("name=")>=0&&(x=h.replace(/(.*[\n\s\S]*?)name="([^"]*)"(.*[\n\s\S]*)/,"$2")),h.indexOf("sheetId=")>0&&(l=Number(h.replace(/(.*[\n\s\S]*?)sheetId="([^"]*)"(.*[\n\s\S]*)/,"$2")),isNaN(l)&&(l=N+1)),p.set("sheet"+l,x),C["sheet"+l]=x}),i.isNameSet=!0),i.counter++})})})})}).catch(t=>{throw t})}}}}); diff --git a/dist/read-utils-D8LB9Gmq.cjs b/dist/read-utils-D8LB9Gmq.cjs new file mode 100644 index 0000000..c55b446 --- /dev/null +++ b/dist/read-utils-D8LB9Gmq.cjs @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./index-CzrjgJVS.cjs");function M(s){return/t="s".*?(.*?)<\/t>/,r=s.match(a);return r?r[1]:null}function R(s){const a=/(.*?)<\/v>/,r=s.match(a);return r?r[1]:null}function j(s){const a=/r="(.*?)"/,r=s.match(a);return r?r[1]:null}async function q(s,a=!1,r){let O,N=!1;typeof r=="function"?(O=r,N=!0):O=fetch;let x=[],y=new Map,b={},A=[],C={},E={},k=!1;function V(t,T){let g=0,u=[],m=T.match(//g);if(Array.isArray(m)&&m.forEach(n=>{let f=R(n);M(n)&&f&&(f=A[parseInt(f)]);const p=j(n);let i=I.getColRowBaseOnRefString(p,I.cols);typeof u[i.row]>"u"&&(u[i.row]=[]),u[i.row][i.col]=f,g=Math.max(i.col,g)}),t.indexOf("xl/worksheets/sheet")==0){let n=t.substring(14,t.lastIndexOf("."));y.has(n)&&(n=y.get(n)),C[n]=u,E[n]=g}}return await O(s).then(t=>{if(t==null||t==null)throw"response is null";return N?t:a?t.arrayBuffer():t.blob()}).then(async t=>{const g=(await Promise.resolve().then(()=>require("./jszip.min-jYEVHKmD.cjs")).then(m=>m.jszip_min)).default;let u=0;return await new Promise((m,n)=>{g.loadAsync(t).then(function(f){const p=Object.keys(f.files);u=p.length;let i=new Proxy({counter:0,isNameSet:!1},{set(e,o,c){if(o==="isNameSet")return e.isNameSet=c,!0;if(typeof c!="number")throw"value most be number";return e.counter=c,e.isNameSet&&e.counter===u&&m({data:C,sheetNameObject:b,sheetName:y.entries(),maxLengthOfColumn:E}),!0},get(e,o,c){return o==="isNameSet"?e.isNameSet:e.counter}});p.forEach(function(e){f.files[e].async("string").then(function(o){if(e.indexOf("sharedStrings")>=0){let c=o.match(//g);Array.isArray(c)&&c.forEach(S=>{let h=S.match(//g);if(Array.isArray(h)){let w=h.reduce((l,d)=>l+P(d),"");A.push(w)}}),k=!0,x.length>0&&(x.forEach(S=>{V(S.filename,S.fileData)}),x=[])}e.indexOf("sheet")>=0&&(k?V(e,o):x.push({filename:e,fileData:o})),e.indexOf("workbook")>=0&&(o.replace(/(.*[\n\s\S]*)()(.*[\n\s\S]*)/,"$2").split("{let l=w+1,d="Sheet "+l;h.indexOf("name=")>=0&&(d=h.replace(/(.*[\n\s\S]*?)name="([^"]*)"(.*[\n\s\S]*)/,"$2")),h.indexOf("sheetId=")>0&&(l=Number(h.replace(/(.*[\n\s\S]*?)sheetId="([^"]*)"(.*[\n\s\S]*)/,"$2")),isNaN(l)&&(l=w+1)),y.set("sheet"+l,d),b["sheet"+l]=d}),i.isNameSet=!0),i.counter++})})})})}).catch(t=>{throw t})}exports.extractExcelData=q; diff --git a/dist/read-utils-DODcKE84.js b/dist/read-utils-DODcKE84.js new file mode 100644 index 0000000..26ca0f0 --- /dev/null +++ b/dist/read-utils-DODcKE84.js @@ -0,0 +1 @@ +define(["require","exports","./index-BYjrfbvd"],function(M,N,b){"use strict";function P(s){return/t="s".*?(.*?)<\/t>/,r=s.match(a);return r?r[1]:null}function B(s){const a=/(.*?)<\/v>/,r=s.match(a);return r?r[1]:null}function D(s){const a=/r="(.*?)"/,r=s.match(a);return r?r[1]:null}async function $(s,a=!1,r){let O,A=!1;typeof r=="function"?(O=r,A=!0):O=fetch;let x=[],y=new Map,C={},E=[],k={},V={},T=!1;function j(t,I){let g=0,f=[],i=I.match(//g);if(Array.isArray(i)&&i.forEach(n=>{let h=B(n);P(n)&&h&&(h=E[parseInt(h)]);const p=D(n);let c=b.getColRowBaseOnRefString(p,b.cols);typeof f[c.row]>"u"&&(f[c.row]=[]),f[c.row][c.col]=h,g=Math.max(c.col,g)}),t.indexOf("xl/worksheets/sheet")==0){let n=t.substring(14,t.lastIndexOf("."));y.has(n)&&(n=y.get(n)),k[n]=f,V[n]=g}}return await O(s).then(t=>{if(t==null||t==null)throw"response is null";return A?t:a?t.arrayBuffer():t.blob()}).then(async t=>{const g=(await new Promise((i,n)=>M(["./jszip.min-CGrYsaMq"],i,n)).then(i=>i.jszip_min)).default;let f=0;return await new Promise((i,n)=>{g.loadAsync(t).then(function(h){const p=Object.keys(h.files);f=p.length;let c=new Proxy({counter:0,isNameSet:!1},{set(e,o,u){if(o==="isNameSet")return e.isNameSet=u,!0;if(typeof u!="number")throw"value most be number";return e.counter=u,e.isNameSet&&e.counter===f&&i({data:k,sheetNameObject:C,sheetName:y.entries(),maxLengthOfColumn:V}),!0},get(e,o,u){return o==="isNameSet"?e.isNameSet:e.counter}});p.forEach(function(e){h.files[e].async("string").then(function(o){if(e.indexOf("sharedStrings")>=0){let u=o.match(//g);Array.isArray(u)&&u.forEach(S=>{let m=S.match(//g);if(Array.isArray(m)){let w=m.reduce((l,d)=>l+R(d),"");E.push(w)}}),T=!0,x.length>0&&(x.forEach(S=>{j(S.filename,S.fileData)}),x=[])}e.indexOf("sheet")>=0&&(T?j(e,o):x.push({filename:e,fileData:o})),e.indexOf("workbook")>=0&&(o.replace(/(.*[\n\s\S]*)()(.*[\n\s\S]*)/,"$2").split("{let l=w+1,d="Sheet "+l;m.indexOf("name=")>=0&&(d=m.replace(/(.*[\n\s\S]*?)name="([^"]*)"(.*[\n\s\S]*)/,"$2")),m.indexOf("sheetId=")>0&&(l=Number(m.replace(/(.*[\n\s\S]*?)sheetId="([^"]*)"(.*[\n\s\S]*)/,"$2")),isNaN(l)&&(l=w+1)),y.set("sheet"+l,d),C["sheet"+l]=d}),c.isNameSet=!0),c.counter++})})})})}).catch(t=>{throw t})}N.extractExcelData=$,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}); diff --git a/dist/read-utils-YAGe6NNW.js b/dist/read-utils-YAGe6NNW.js new file mode 100644 index 0000000..d715a4b --- /dev/null +++ b/dist/read-utils-YAGe6NNW.js @@ -0,0 +1,110 @@ +import { g as R, c as T } from "./index-DMAk0ysA.js"; +function B(s) { + return /t="s".*?(.*?)<\/t>/, r = s.match(a); + return r ? r[1] : null; +} +function $(s) { + const a = /(.*?)<\/v>/, r = s.match(a); + return r ? r[1] : null; +} +function j(s) { + const a = /r="(.*?)"/, r = s.match(a); + return r ? r[1] : null; +} +async function P(s, a = !1, r) { + let N, O = !1; + typeof r == "function" ? (N = r, O = !0) : N = fetch; + let x = [], y = /* @__PURE__ */ new Map(), b = {}, A = [], C = {}, k = {}, E = !1; + function V(t, I) { + let g = 0, u = [], m = I.match(//g); + if (Array.isArray(m) && m.forEach((n) => { + let f = $(n); + B(n) && f && (f = A[parseInt(f)]); + const p = j(n); + let i = R(p, T); + typeof u[i.row] > "u" && (u[i.row] = []), u[i.row][i.col] = f, g = Math.max(i.col, g); + }), t.indexOf("xl/worksheets/sheet") == 0) { + let n = t.substring(14, t.lastIndexOf(".")); + y.has(n) && (n = y.get(n)), C[n] = u, k[n] = g; + } + } + return await N(s).then((t) => { + if (t == null || t == null) + throw "response is null"; + return O ? t : a ? t.arrayBuffer() : t.blob(); + }).then(async (t) => { + const g = (await import("./jszip.min-D-TEDr9v.js").then((m) => m.j)).default; + let u = 0; + return await new Promise((m, n) => { + g.loadAsync(t).then(function(f) { + const p = Object.keys(f.files); + u = p.length; + let i = new Proxy( + { + counter: 0, + isNameSet: !1 + }, + { + set(e, o, c) { + if (o === "isNameSet") + return e.isNameSet = c, !0; + if (typeof c != "number") + throw "value most be number"; + return e.counter = c, e.isNameSet && e.counter === u && m({ + data: C, + sheetNameObject: b, + sheetName: y.entries(), + maxLengthOfColumn: k + }), !0; + }, + get(e, o, c) { + return o === "isNameSet" ? e.isNameSet : e.counter; + } + } + ); + p.forEach(function(e) { + f.files[e].async("string").then(function(o) { + if (e.indexOf("sharedStrings") >= 0) { + let c = o.match(//g); + Array.isArray(c) && c.forEach((S) => { + let h = S.match(//g); + if (Array.isArray(h)) { + let w = h.reduce((l, d) => l + M(d), ""); + A.push(w); + } + }), E = !0, x.length > 0 && (x.forEach((S) => { + V(S.filename, S.fileData); + }), x = []); + } + e.indexOf("sheet") >= 0 && (E ? V(e, o) : x.push({ + filename: e, + fileData: o + })), e.indexOf("workbook") >= 0 && (o.replace( + /(.*[\n\s\S]*)()(.*[\n\s\S]*)/, + "$2" + ).split(" { + let l = w + 1, d = "Sheet " + l; + h.indexOf("name=") >= 0 && (d = h.replace( + /(.*[\n\s\S]*?)name="([^"]*)"(.*[\n\s\S]*)/, + "$2" + )), h.indexOf("sheetId=") > 0 && (l = Number( + h.replace( + /(.*[\n\s\S]*?)sheetId="([^"]*)"(.*[\n\s\S]*)/, + "$2" + ) + ), isNaN(l) && (l = w + 1)), y.set("sheet" + l, d), b["sheet" + l] = d; + }), i.isNameSet = !0), i.counter++; + }); + }); + }); + }); + }).catch((t) => { + throw t; + }); +} +export { + P as extractExcelData +}; diff --git a/src/data-model/const-data.ts b/src/data-model/const-data.ts index 7638260..ac2e540 100644 --- a/src/data-model/const-data.ts +++ b/src/data-model/const-data.ts @@ -1,63 +1,34 @@ import { type FormatMap } from "./excel-table"; export const formatMap: FormatMap = { - time: { - key: 165, - value: '', - }, - date: { - key: 187, - value: - '', - }, - short_date: { - key: 14, - }, - fraction: { - key: 13, - }, percentage: { key: 9, }, - float_1: { key: 180, value: '' }, - float_2: { key: 181, value: '' }, - float_3: { - key: 164, - value: '', - }, - float_4: { - key: 182, - value: '', - }, - dollar_rounded: { - key: 183, - value: '', - }, - dollar_2: { - key: 183, - value: '', + fraction: { + key: 13, }, - num_sep: { - key: 184, - value: '', + short_date: { + key: 14, }, - num_sep_1: { - key: 185, - value: '', + yen: { + key: 160, + value: + '', }, - num_sep_2: { - key: 186, - value: '', + "¥": { + key: 160, + value: + '', }, - dollar: { - key: 163, + euro: { + key: 161, value: - '', + '', }, - $: { - key: 163, + "€": { + key: 161, value: - '', + '', }, pound: { key: 162, @@ -69,45 +40,48 @@ export const formatMap: FormatMap = { value: '', }, - euro: { - key: 161, + dollar: { + key: 163, value: - '', + '', }, - "€": { - key: 161, + "$": { + key: 163, value: - '', + '', }, - yen: { - key: 160, - value: - '', + float_3: { + key: 164, + value: '', }, - "¥": { - key: 160, + time: { + key: 165, + value: '', + }, + "ريال": { + key: 171, value: - '', + '', }, - CHF: { - key: 179, + "₽3": { + key: 172, value: - '', + '', }, - ruble: { - key: 178, + "₽2": { + key: 173, value: - '', + '', }, - "₽": { - key: 178, + "₽1": { + key: 174, value: - '', + '', }, - "֏": { - key: 177, + "₼1": { + key: 175, value: - '', + '', }, manat: { key: 176, @@ -119,30 +93,56 @@ export const formatMap: FormatMap = { value: '', }, - "₼1": { - key: 175, + "֏": { + key: 177, value: - '', + '', }, - "₽1": { - key: 174, + ruble: { + key: 178, value: - '', + '', }, - "₽2": { - key: 173, + "₽": { + key: 178, value: - '', + '', }, - "₽3": { - key: 172, + CHF: { + key: 179, value: - '', + '', }, - "ريال": { - key: 171, + float_1: { key: 180, value: '' }, + float_2: { key: 181, value: '' }, + float_4: { + key: 182, + value: '', + }, + dollar_2: { + key: 183, + value: '', + }, + num_sep: { + key: 184, + value: '', + }, + num_sep_1: { + key: 185, + value: '', + }, + num_sep_2: { + key: 186, + value: '', + }, + date: { + key: 187, value: - '', + '', + }, + dollar_rounded: { + key: 188, + value: '', }, };