UNPKG

@sheetxl/models

Version:

Models - A Headless javascript spreadsheet library.

160 lines 5.14 kB
import { CellRangeCoords, RemoveListener, SetOptions } from "@sheetxl/common"; import { SerializableProperties } from "../primitives"; import { ITableStyle } from "../cell"; export interface UpdateTableModelOptions extends SetOptions { } export interface TableStyleInfo { /** * A string representing the name of the table style to use with this table. * If the style name isn't valid then the spreadsheet application should use default style. */ name: string; /** * A Boolean indicating whether row stripe formatting is applied. True when style row stripe formatting is applied. * @defaultValue true */ showRowStripes?: boolean; /** * A Boolean indicating whether column stripe formatting is applied. True when style column stripe formatting is applied. * @defaultValue false */ showColumnStripes?: boolean; /** * A Boolean indicating whether the first column in the table should have the style applied. True if the first column has the style applied. * @defaultValue false */ showFirstColumn?: boolean; /** * A Boolean indicating whether the last column in the table should have the style applied. True if the last column has the style applied. * @defaultValue false */ showLastColumn?: boolean; } export interface AutoFilter { ref?: string; /** * NOT IMPLEMENTED */ sortState?: any; /** * NOT IMPLEMENTED */ filterColumns?: any; } /** * Element representing a single column for a table */ export interface TableColumn { /** * A string representing the unique caption of the table column. * This is what shall be displayed in the header row in the UI, and is referenced through functions. * This name shall be unique per table. */ name: string; } /** * A unique table definition useful for filter auto-styling and connecting to data-sources. * @see {@link ITableModel} */ export interface TableModelValues { /** * The unique name of the table */ name: string; /** * The range on the relevant sheet that the table occupies expressed using A1 style referencing. * The reference shall include the totals row if it is shown */ ref: CellRangeCoords; /** * A string representing the name of the table. This is the name that shall be used in formula references, * and displayed in the UI to the spreadsheet user. * This name shall not have any spaces in it, and it must be unique amongst all other displayNames and * definedNames in the workbook. The character lengths and restrictions are the same as for definedNames. * * See SpreadsheetML Reference - Workbook definedNames section for details. */ displayName?: string; /** * An integer representing the number of header rows showing at the top of the table. * 0 means that the header row is not shown * @defaultValue 1 */ headerRowCount?: number; /** * An integer representing the number of totals rows that shall be shown at the bottom of the table. * * @defaultValue 0 */ totalsRowCount?: number; autoFilter?: AutoFilter; sortState?: any; columns?: TableColumn[]; /** * If not specified than the default table style is used * If the style name isn't valid then uses a 'none' style. */ styleInfo?: TableStyleInfo; } /** * Listener for table model events. */ export interface ITableModelListener { /** * Called when the TableModel changes. * * @param model */ onTableChange?(model: ITableModel): void; /** * Called when the table is closed. * * @param model */ onClose?(model: ITableModel): void; } /** * */ export interface ITableModel extends TableModelValues { /** * Returns the current style used. */ getTableStyle(): ITableStyle; /** * Update the table with the new values. * @param values * @param options */ update(values: SerializableProperties<TableModelValues>, options?: UpdateTableModelOptions): void; insertRows(offset: number, count: number): void; removeRows(offset: number, count: number): void; insertColumns(offset: number, count: number): void; removeColumns(offset: number, count: number): void; /** * Register for updates * @param listener */ addListener(listener: ITableModelListener): RemoveListener; /** * Saves the current state of the table to a JSON object. */ toJSON(): SerializableProperties<TableModelValues>; /** * Free all resources associated with the sheet and mark as read-only. * @remarks * This is called by workbooks when the sheet is closed * @see {@link addListener} for closeEvent */ close(): void; /** * Returns true if the table has been closed. */ isClosed(): boolean; /** * Purely for runtime inspection */ readonly isModelTable: true; } export declare const DEFAULT_TABLE_STYLE_INFO: Partial<TableStyleInfo>; //# sourceMappingURL=ITableModel.d.ts.map