UNPKG

xlsx-extractor

Version:
149 lines (148 loc) 4.22 kB
/// <reference types="node" /> /** * This represents an entry in the zip file. If the entry comes from an existing archive previously loaded, the content will be automatically decompressed/converted first. * @see https://stuk.github.io/jszip/documentation/api_zipobject.html */ export declare type ZipObject = { /** the absolute path of the file. */ name: string; /** `true` if this is a directory. */ dir: boolean; /** the last modification date. */ date: Date; /** the comment for this file. */ comment: string; /** The UNIX permissions of the file, if any. 16 bits number. */ unixPermissions: number; /** The DOS permissions of the file, if any. 6 bits number. */ dosPermissions: number; /** the options of the file. The available options. */ options: { compression: (name: string, data: string | ArrayBuffer | Uint8Array | Buffer | Blob | Promise<any> | WritableStream) => void; }; /** Files. */ files: any; }; /** Sheet data. */ export declare type SheetData = { /** Sheet name. */ name: string; /** Data obtained by converting the XML of the sheet to the JavaScript Object. */ sheet: any; /** Data obtained by converting the XML of the shared strings to the JavaScript Object. */ strings?: any; }; /** Sheet size. */ export declare type SheetSize = { /** Row of sheet. */ row: { /** Minimum value of row. */ min: number; /** Maximum value of row. */ max: number; }; /** Column of sheet. */ col: { /** Minimum value of column. */ min: number; /** Maximum value of column. */ max: number; }; }; /** It is a cell in a sheet. */ export declare type Cell = { /** Row position. */ row: number; /** Column position. */ col: number; /** Type.. */ type: string; /** Value string. */ value: string; }; /** It is the position of the cell. */ declare type Position = { /** Row position. */ row: number; /** Column position. */ col: number; }; /** * Create a empty cells. * @param rows Rows count. * @param cols Columns count. * @return Cells. */ export declare const createEmptyCells: (rows: number, cols: number) => string[][]; /** * Get a cells from a rows. * @param rows Rows. * @return Cells. */ export declare const getCells: (rows: any[]) => Cell[]; /** * Get the coordinates of the cell. * @param text Position text. Such as "A1" and "U109". * @return Position. */ export declare const getPosition: (text: string) => Position; /** * Get a sheet data. * @param zip Extract data of XLSX (Zip) file. * @param index Index of sheet. Range of from 1 to XlsxExtractor.count. * @returns Sheet data. */ export declare const getSheetData: (zip: ZipObject, index: number) => Promise<SheetData>; /** * Gets the number of sheets. * @param zip Extract data of XLSX (Zip) file. * @returns Number of sheets */ export declare const getSheetInnerCount: (zip: ZipObject) => number; /** * Get the range of the sheet. * @param sheet Sheet data. * @param cells Cells. * @return Range. */ export declare const getSheetSize: (sheet: any, cells: any[]) => SheetSize; /** * Convert the column text to number. * @param text Column text, such as A" and "AA". * @return Column number, otherwise -1. */ export declare const numOfColumn: (text: string) => number; /** * Parse the `r` element of XML. * @param r `r` elements. * @return Parse result. */ export declare const parseR: (r: any[]) => string; /** * Parse the `t` element of XML. * @param t `t` elements. * @return Parse result. */ export declare const parseT: (t: any[]) => string; /** * Parse the XML text. * @param xml XML text. * @return XML parse task. */ export declare const parseXML: (xml: string) => Promise<any>; /** * Extract a zip file. * @param path Zip file path. * @return If success zip object, otherwise null. * @throws Failed to expand the XLSX file. */ export declare const unzip: (path: string) => ZipObject; /** * Get a value from the cell strings. * * @param str Cell strings. * * @return Value. */ export declare const valueFromStrings: (str: any) => string; export {};