@beenotung/tslib
Version:
utils library in Typescript
50 lines (49 loc) • 2.6 kB
TypeScript
/**
* Using @e965/xlsx instead of xlsx for vulnerability fixes
*/
import type { Sheet2CSVOpts, Sheet2FormulaOpts, Sheet2HTMLOpts, Sheet2JSONOpts, WorkBook, WorkSheet, WritingOptions } from '@e965/xlsx';
export type * from '@e965/xlsx';
export declare function wrap_into_workbook(data: object[] | Record<string, object[]>): Promise<{
workbook: WorkBook;
get_default_sheet_name: () => string;
get_sheet: (name?: string) => WorkSheet;
get_sheet_as_json: (name?: string, options?: Sheet2JSONOpts) => unknown[];
get_sheet_as_csv: (name?: string, options?: Sheet2CSVOpts) => string;
get_sheet_as_text: (name?: string, options?: Sheet2CSVOpts) => string;
get_sheet_as_html: (name?: string, options?: Sheet2HTMLOpts) => string;
get_sheet_as_formulae: (name?: string, options?: Sheet2FormulaOpts) => string[];
XLSX: typeof import("@e965/xlsx");
}>;
export declare function write_xlsx_file(file: string, data: object[] | Record<string, object[]>, options?: WritingOptions): Promise<void>;
export declare function read_xlsx_file(file: string): Promise<{
workbook: WorkBook;
get_default_sheet_name: () => string;
get_sheet: (name?: string) => WorkSheet;
get_sheet_as_json: (name?: string, options?: Sheet2JSONOpts) => unknown[];
get_sheet_as_csv: (name?: string, options?: Sheet2CSVOpts) => string;
get_sheet_as_text: (name?: string, options?: Sheet2CSVOpts) => string;
get_sheet_as_html: (name?: string, options?: Sheet2HTMLOpts) => string;
get_sheet_as_formulae: (name?: string, options?: Sheet2FormulaOpts) => string[];
XLSX: typeof import("@e965/xlsx");
}>;
export type WrappedWorkbook = Awaited<ReturnType<typeof wrap_workbook>>;
declare function wrap_workbook(workbook: WorkBook, XLSX: typeof import('@e965/xlsx')): Promise<{
workbook: WorkBook;
get_default_sheet_name: () => string;
get_sheet: (name?: string) => WorkSheet;
get_sheet_as_json: (name?: string, options?: Sheet2JSONOpts) => unknown[];
get_sheet_as_csv: (name?: string, options?: Sheet2CSVOpts) => string;
get_sheet_as_text: (name?: string, options?: Sheet2CSVOpts) => string;
get_sheet_as_html: (name?: string, options?: Sheet2HTMLOpts) => string;
get_sheet_as_formulae: (name?: string, options?: Sheet2FormulaOpts) => string[];
XLSX: typeof import("@e965/xlsx");
}>;
export declare function get_worksheet_headers(worksheet: WorkSheet): {
col: string;
value: any;
}[];
export declare function fill_by_headers<T>(args: {
rows: Record<string, T>[];
headers: string[];
default_value?: T;
}): Record<string, T>[];