UNPKG

@mertdeveci55/univer-import-export

Version:

Excel/CSV import and export library for Univer spreadsheets with full format preservation

106 lines (105 loc) 3.14 kB
/** * Univer-specific utility functions for proper data conversion * * This file ensures proper handling of Univer data types during export * to maintain perfect symmetry with the import process. */ export declare enum BooleanNumber { FALSE = 0, TRUE = 1 } export declare enum CellValueType { STRING = 1, NUMBER = 2, BOOLEAN = 3, FORCE_STRING = 4 } /** * Convert Univer BooleanNumber to JavaScript boolean * Univer uses 0 and 1 to represent false and true * * @param value - BooleanNumber value (0, 1, or undefined) * @returns JavaScript boolean */ export declare function fromBooleanNumber(value: BooleanNumber | number | undefined): boolean; /** * Convert JavaScript boolean to Univer BooleanNumber * * @param value - JavaScript boolean * @returns BooleanNumber (0 or 1) */ export declare function toBooleanNumber(value: boolean | undefined): BooleanNumber; /** * Convert Univer cell value based on cell type * Properly handles the different CellValueType cases * * @param cell - Cell data from Univer * @returns Properly typed value for Excel */ export declare function convertCellValue(cell: any): any; /** * Convert Univer IDocumentData (rich text) to Excel rich text format * * @param doc - Univer document data * @returns Excel rich text array */ export declare function convertUniverDocToExcelRichText(doc: any): any; /** * Convert Univer color object to Excel color format * * @param color - Univer color object * @returns Excel ARGB color string */ export declare function convertUniverColorToExcel(color: any): any; /** * Convert Univer range to Excel range string * * @param range - Univer range object * @returns Excel range string (e.g., "A1:C3") */ export declare function convertUniverRangeToExcel(range: any): string | undefined; /** * Resolve style from Univer style registry * * @param styleRef - Style reference (string ID or inline object) * @param styles - Style registry * @returns Resolved style object */ export declare function resolveStyle(styleRef: string | any, styles: Record<string, any>): any; /** * Check if a cell has a formula * * @param cell - Cell data * @returns True if cell has a formula */ export declare function hasFormula(cell: any): boolean; /** * Check if a cell is part of an array formula * * @param cell - Cell data * @param arrayFormulas - Array formulas for the sheet * @returns True if cell is part of an array formula */ export declare function isArrayFormulaCell(cell: any, arrayFormulas: any[]): boolean; /** * Get number format for cell * * @param cell - Cell data * @param style - Resolved style object * @returns Number format string */ export declare function getCellNumberFormat(cell: any, style: any): string | undefined; /** * Convert Univer border style to Excel * * @param border - Univer border object * @returns Excel border object */ export declare function convertBorderToExcel(border: any): any; /** * Convert Univer alignment to Excel * * @param style - Univer style object * @returns Excel alignment object */ export declare function convertAlignmentToExcel(style: any): any;