UNPKG

taktik-simple-spreadsheet-reader

Version:
136 lines (135 loc) 3.89 kB
declare type ICell = { cell: string; value: string; }; declare type IParsedCells = Array<ICell>; export declare type SpredsheedCell = { cell: string; value: string; rows: string; coll: string; }; /** * A simple reader for a Google spreadsheet publish on web. */ export declare class SpreadsheetReader { private readonly apiKey; private sheetsProperties?; private _currentPage; private sheetsData; private readonly spreadsheetsId?; private httpClient; private _xmlError?; /** * gets the current page, indexed at 0 */ get currentPage(): number; /** * sets the current page, indexed at 0 */ set currentPage(page: number); /** * get the total number of pages the sheet has */ get numberOfPages(): number; /** * XML string of the error message */ get xmlError(): string | undefined; /** * get parsed cells */ get parsedCells(): IParsedCells; /** * List od cells loaded from google spreadsheet */ get cellsList(): Array<SpredsheedCell>; /** * get the number of raw used in the spreadsheet */ get maxRow(): number; /** * get the number of column used in the spreadsheet. */ get maxColl(): string; constructor(spreadsheetsUrlOrId: string, apiKey: string); private processSpreadsheet; private static getColumnLettersFromIndex; private parseSheetValues; /** * Load spreadsheet cells values */ loadSpreadsheetData(): Promise<void>; /** * get value of a cell * @param cellId * @param page */ getCellValue(cellId: string, page?: number): 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; private static lettersGenerator; private static numberGenerator; private createHeadCell; private generateTable; } export {};