UNPKG

simple-spreadsheet-reader

Version:
125 lines (124 loc) 4.13 kB
import { httpclient } from 'typescript-http-client'; export declare type SpredsheedCell = { cell: string; value: string; rows: number; coll: string; collNb: number; }; export declare type GoogleJsonSpreadsheet = { [key: string]: any; }; /** * A simple reader for a Google spreadsheet publish on web. */ export declare class SpreadsheedReader { protected spreadsheetsIs?: string; protected httpClient: httpclient.HttpClient; protected _xmlError?: string; protected _rawJson?: GoogleJsonSpreadsheet; protected _cellsList?: Array<SpredsheedCell>; protected _maxRaw?: number; protected _maxColl?: string; /** * XML string of the error message */ get xmlError(): string | undefined; /** * get raw JSON loaded from google spreadsheet */ get rawJson(): GoogleJsonSpreadsheet; /** * List od cells loaded from google spreadsheet */ get cellsList(): Array<SpredsheedCell>; /** * get the number of raw used in the spreadsheet */ get maxRaw(): number; /** * get the number of column used in the spreadsheet. */ get maxColl(): string; constructor(spreadsheetsUrlOrId: string); protected processSpreadsheets(rawJson: GoogleJsonSpreadsheet): GoogleJsonSpreadsheet; /** * Load spreadsheet data */ loadSpreadsheetData(): Promise<GoogleJsonSpreadsheet>; /** * get value of a cell * @param cellId */ getCellValue(cellId: string): string | undefined; /** * gel all lines of the spreadsheet in an array of array */ getAllLines(): Array<Array<string | undefined>>; /** * Compute Node elements of the table. * In case of errors the node will contains the error message. * * *classes* * - ssr-table: class of the root elements of the table * - ssr-cell-head: class of header cells * - ssr-cell-data: class of cells contains data * * *id* * - All data Element have id="ssr-${cellID}" * * *results HTML* * * ```html * <table class="ssr-table"> <thead> <tr> <td class="ssr-cell-head"></td> <td class="ssr-cell-head">A</td> <td class="ssr-cell-head">B</td> </tr> </thead> <tbody> <tr> <td class="ssr-cell-head">1</td> <td cell-id="A1" id="ssr-A1" class="ssr-cell-data">text</td> <td cell-id="B1" id="ssr-B1" class="ssr-cell-data">value</td> </tr> <tr> <td class="ssr-cell-head">2</td> <td cell-id="A2" id="ssr-A2" class="ssr-cell-data"></td> <td cell-id="B2" id="ssr-B2" class="ssr-cell-data">other</td> </tr> </tbody> </table> ``` * * <table class="ssr-table"> <thead> <tr> <td class="ssr-cell-head"></td> <td class="ssr-cell-head">A</td> <td class="ssr-cell-head">B</td> </tr> </thead> <tbody> <tr> <td class="ssr-cell-head">1</td> <td cell-id="A1" id="ssr-A1" class="ssr-cell-data">text</td> <td cell-id="B1" id="ssr-B1" class="ssr-cell-data">value</td> </tr> <tr> <td class="ssr-cell-head">2</td> <td cell-id="A2" id="ssr-A2" class="ssr-cell-data"></td> <td cell-id="B2" id="ssr-B2" class="ssr-cell-data">other</td> </tr> </tbody> </table> */ getTable(): Node; protected static formatColl(cells: Array<SpredsheedCell>, maxColl: string): Array<string | undefined>; protected static lettersGenerator(maxLetters: string): Generator<string>; protected static numberGenerator(maxLines?: number): Generator<number>; protected createHeadCell(cellContaint: string | undefined): HTMLTableDataCellElement; protected generateTable(maxRaw: number, maxCell: string): HTMLTableElement; }