Interface ISheetHeadersModel<T, P, U>

Objects that support interfacing with a transactional store implement this interface.

interface ISheetHeadersModel<T, P, U> {
    addEventListener(type, listener, options?): RemoveListener;
    autoFit(addresses, options?): void;
    close(): void;
    findIndex(offset): number;
    findOffset(index): number;
    fromJSON(json): void;
    getDefaultHeaderSize(): number;
    getHeader(offset): T;
    getHeaderBounds(): RunCoords;
    getHeaderSize(indexFrom, indexTo?): number;
    getHeaderText(index): string;
    getMaxHeaderBounds(): RunCoords;
    getMaxHeaderSize(): number;
    getMinHeaderSize(): number;
    getRange(address?): ISheetHeaderRange<U>;
    hasCustomFormats(): boolean;
    hasCustomStyles(): boolean;
    hiddenHeadersAt(index, forward?): number;
    insertHeaders(index, amount): void;
    isProtected(): boolean;
    orientation(): HeaderOrientation;
    pushTransaction(description?): ITransaction;
    removeHeaders(index, amount): void;
    scaleFactor(): number;
    setHeaderPairs(pairs, options?): RunCoords[];
    sheet(): ISheetModel;
    sheetStyle(): ISheetStyle;
    toJSON(): SheetHeaderJSON<P>;
    update(address, update, options?): void;
}

Type Parameters

Hierarchy (view full)

Methods

  • Add a listener. This is very similar to default javascript listeners except the offer a few additional options and there is no remove listener.

    These add listeners return a function that can be called to remove the listener. Additionally they honor transactional boundaries.

    Listeners are fired in the order that they are added.

    Parameters

    Returns RemoveListener

  • Returns void

  • Finds the index for the given header offset

    Parameters

    • offset: number

    Returns number

  • Finds the offset in pixels for the given header index

    Parameters

    • index: number

    Returns number

  • The default header size if not adjusted.

    Returns number

  • Returns the header at a given offset. Will only return null for invalid header offset. To get a list of headers use

    Parameters

    • offset: number

    Returns T

  • Return the bounds for headers that contain styling.

    Returns RunCoords

    Remarks

    • This is NOT the last cell that may have data or has been resized.
    • This also has nothing to do with the selection bounds.
  • Returns the size of the header in pixels. If a second argument is passed it will be the size of all the headers within the range. Note - It is expected that indexFrom will always be less than or equal to indexTo

    Parameters

    • indexFrom: number
    • Optional indexTo: number

    Returns number

  • Returns a displayable title for the given index.

    Parameters

    • index: number

    Returns string

  • The maximum cell bounds allowed for the header.

    Returns RunCoords

    Remarks

  • The maximum size of the header in native units.

    Returns number

    Default Value

    unbounded
    
  • The minimum size of the header in native units.

    Returns number

    Default Value

    0.
    
  • Will return true if any of the headers have the isCustomFormats flag set to true

    Returns boolean

  • Will return true if any of the headers have a custom style (not Normal)

    Returns boolean

  • This is a very specific optimization function. When hiding many headers instead of scanning we can just skip. If this returns zero there are no hidden headers immediately following this one. If a count of 1 then only this header is hidden

    Parameters

    • index: number
    • Optional forward: boolean

      searches forward. defaults to true

    Returns number

    count

  • Insert new blank headers at the given index

    Parameters

    • index: number
    • amount: number

    Returns void

  • Returns if the header is readonly.

    Returns boolean

    Default Value

    false
    
  • Begins a transaction but puts it onto a global stack. This will batch all 'transactional' changes until they have all be committed or rolled back.

    Parameters

    • Optional description: string

    Returns ITransaction

    Remarks

    Any changes that are made to this object will be reflected in the local sheet but not committed to the transactional store until the batch is popped.

  • Remove headers at the given index

    Parameters

    • index: number
    • amount: number

    Returns void

  • All header sizes are returned in pixels. This is done by multiplying the scaleFactor by the size on the cellHeader.

    Returns number

  • Sets the headers. This supports setting values as a batch. Note - When setting headers the cells references by this sheet will not update. To ensure they are updated you must also call setCellPairs with the range of the header.

    Parameters

    Returns RunCoords[]

  • Simplified api provided to be similar to range update.

    Parameters

    Returns void

    Remarks

    This only supports one range at a time but offers a few flavors

    • sheetXl.getWorkbook().getSheet().getColumnHeaders().update(5, { size: '100px' }); // 0-based index
    • sheetXl.getWorkbook().getSheet().getColumnHeaders().update({ min: 3, max: 4 }, { size: '100px' }); // 0-based index
    • sheetXl.getWorkbook().getSheet().getColumnHeaders().update('e:f', { size: '100px' }); // 1-based a1 style
    • sheetXl.getWorkbook().getSheet().getColumnHeaders().update({ colStart: 3, colEnd: 4 }, { size: '100px' }); // 0-based index
    • sheetXl.getWorkbook().getSheet().getRowHeaders().update('5:7', { size: '100px' }); // 1-based a1 style
    • sheetXl.getWorkbook().getSheet().getRowHeaders().update({ rowStart: 3, rowEnd: 4 }, { size: '100px' }); // 0-based index