UNPKG

@sheetxl/models

Version:

Models - A Headless javascript spreadsheet library.

89 lines (88 loc) 5.59 kB
import { CopyClipboardArgument, CellRangeCoords, CartesianDirection, EditMode, Point, Bounds } from "@sheetxl/common"; import { CellUpdateFromStringOptions } from "../cell/CellTypes"; import CellRange from "../range/CellRange"; import { RunCoords } from "../run/RunUtils"; import { ICellModel, ICellStyle, RangeUpdateValue, RangeOrientation, ICellValue, CellUpdate, CellAddressValuePair, CellHeaderVisitor, HeaderOrientation, CellHeaderVisitorOptions, CellVisitor, CellVisitorOptions, CellCoordsAddress, CellRangeCoordsAddress, CellHeaderRangeAddress, CellValueComparator, RangeSortOptions, CellSimpleUpdateValue } from "../cell"; import { CellSelection } from "./ISheetView"; import { ISheetModel, ISheetRange, SheetProtection, CopySheetSource, CopyableSheetItem } from "./ISheetModel"; export declare const DEFAULT_SHEET_PROTECTION: SheetProtection; export declare const DEFAULT_CELL_TYPE_COMPARATORS: CellValueComparator[]; export declare const RANGE_INVALID_REF: ISheetRange; /** * Implementation of date/number/currency parsing -We could to move to a more robust solution but I believe we have all of the accounting rules that Excel has -https://github.com/BrightspaceUI/intl - https://github.com/openexchangerates/accounting.js, https://github.com/dinerojs/dinero.js -TODO internationalization - https://github.com/BrightspaceUI/intl */ export declare const createCellUpdateFromString: (strValue: string, style?: ICellStyle, options?: CellUpdateFromStringOptions) => CellUpdate; export declare const decodeRange: (range: CellCoordsAddress | CellRangeCoordsAddress, defaultRange?: CellRangeCoords) => CellRangeCoords; /** * Converts a CellAddressValuePair to a usable range and update by evaluating all 'convenience' properties * * @param pair * @returns */ export declare const pairToRangeAndUpdate: (pair: CellAddressValuePair, maxRange: CellRangeCoords) => { range: CellRangeCoords; update: CellSimpleUpdateValue; }; export declare const selectionFromRanges: (ranges: CellRangeCoords[], last?: boolean) => CellSelection; export declare const rangeFromActiveSelection: (selection: CellSelection) => CellRangeCoords; /** * Returns a union of all ranges in the selection */ export declare const rangeFromSelection: (selection: CellSelection) => CellRangeCoords; export declare const rangesFromSelection: (selection: CellSelection) => CellRangeCoords[]; export declare const parseHeaderRangeAddress: (address: CellHeaderRangeAddress, orientation: HeaderOrientation, defaultRange?: CellRangeCoords) => RunCoords; export declare class ReferencedSheetSource implements CopySheetSource { protected _sheetModel: ISheetModel; protected _ranges: CellRangeCoords[]; protected _copyableItems: CopyableSheetItem[]; protected _args: CopyClipboardArgument; constructor(sheetModel: ISheetModel, args?: CopyClipboardArgument, ranges?: CellRangeCoords[], copyableItems?: CopyableSheetItem[]); editMode(): EditMode; isCut(): boolean; name(): string; rangesFrom(): CellRangeCoords[]; rangeFrom(): CellRangeCoords; scanCells(visitor: CellVisitor, options?: CellVisitorOptions): void; getCopyableItems(): CopyableSheetItem[]; scanRowHeaders(visitor: CellHeaderVisitor, options?: CellHeaderVisitorOptions): void; scanColHeaders(visitor: CellHeaderVisitor, options?: CellHeaderVisitorOptions): void; onCopy(): boolean; onCancel(): void; onPaste(): boolean; sheetModel(): ISheetModel; get isCopySheetSource(): true; } /** * Given a selection, find the 'natural' bounding area to sort. * @param selection * @param orientation When checking for header and default sort criteria this is the orientation to use. @defaultValue RangeOrientation.Rows */ export declare const getDefaultSortCriteria: (sheetModel: ISheetModel, selection?: Partial<CellSelection>, orientation?: RangeOrientation) => { range: CellRangeCoords; options: RangeSortOptions; headers: Map<number, string>; }; /** * Returns the cells as an ordered list of ranges. The first range is the active range. * If there are no ranges then the active coord will be returns as a range. * @remarks * * Always return at least 1 range. * * Assumes a valid complete CellSelection */ export declare const cellSelectionToRanges: (cellSelection: CellSelection) => CellRangeCoords[]; export declare const expandRangeToColumns: (range: CellRangeCoords[], after?: boolean) => CellRangeCoords[]; export declare const expandRangeToRows: (range: CellRangeCoords[], after?: boolean) => CellRangeCoords[]; export declare const nonOverlappingDrawingOffset: (sheet: ISheetModel, destination: Bounds, shiftX?: boolean, shiftY?: boolean) => Point; export declare const createRangeFrom2DArray: (data: any[][], sheetName?: string) => CellRange; /** * Default insert shift for a given range */ export declare const insertShiftFromRange: (range: CellRangeCoords) => CartesianDirection.Down | CartesianDirection.Right; export declare const rangeAddressToRangeCoords: (addresses: CellRangeCoordsAddress | CellRangeCoordsAddress[], defaultRange: CellRangeCoords) => CellRangeCoords[]; export declare const rangeUpdateValueToPairs: (value: RangeUpdateValue, range?: CellRangeCoords) => CellAddressValuePair[]; export declare const rangeAs2DArray: (forEach: (visitor: CellVisitor, options?: CellVisitorOptions) => void, includeHiddenHeaders: boolean, asCells: boolean, datesAsJSDate: boolean) => ICellModel[][] | ICellValue[][]; export declare const stringFromCells: (cells: ICellModel[], separator?: string) => string; //# sourceMappingURL=SheetUtils.d.ts.map