@sheetxl/sdk
Version:
SDK - A high-performance, embeddable spreadsheet engine.
1,322 lines (1,252 loc) • 740 kB
TypeScript
import { Bounds } from '@sheetxl/utils';
import { CellCoords } from '@sheetxl/utils';
import { ChainedError } from '@sheetxl/utils';
import { CompiledModule } from '@sheetxl/scripting';
import { CompileOptions } from '@sheetxl/scripting';
import { CompileResults } from '@sheetxl/scripting';
import { CoordUtils } from '@sheetxl/utils';
import { Dimensions } from '@sheetxl/utils';
import { Direction } from '@sheetxl/utils';
import { EditMode } from '@sheetxl/utils';
import { FetchArgs } from '@sheetxl/utils';
import { FormulaError } from '@sheetxl/primitives';
import { IFormulaContext } from '@sheetxl/primitives';
import { IFunction } from '@sheetxl/primitives';
import { IRange } from '@sheetxl/primitives';
import { IReferenceRange } from '@sheetxl/primitives';
import { IRichData } from '@sheetxl/primitives';
import { IRuntime } from '@sheetxl/primitives';
import { JSONSerializableAsync } from '@sheetxl/utils';
import { JSScalar } from '@sheetxl/primitives';
import { JSScalarUpdate } from '@sheetxl/primitives';
import { Point } from '@sheetxl/utils';
import { Properties } from 'csstype';
import { RangeCoords } from '@sheetxl/utils';
import { RangeOrientation } from '@sheetxl/utils';
import { Rectangle } from '@sheetxl/utils';
import { ReferenceableClipboard } from '@sheetxl/utils';
import { RunCoords } from '@sheetxl/utils';
import { Scalar } from '@sheetxl/primitives';
import { ScalarType } from '@sheetxl/primitives';
import { SelectionCoords } from '@sheetxl/utils';
import { TextAlign } from 'csstype';
import { TopLeft } from '@sheetxl/utils';
import { UndoManager } from '@sheetxl/utils';
/**
* Abstract implement of {@link IAnchorItem}.
*/
declare abstract class AbstractAnchored<STATE extends AbstractAnchored.State = AbstractAnchored.State, VIEW extends AbstractAnchored.CommitView = AbstractAnchored.CommitView, EVENTS extends IAnchored.Events = IAnchored.Events> implements IAnchored, IListener.ISource<IAnchored> {
protected _emitter: ListenerEmitter<IAnchored, EVENTS>;
protected _options: IAnchored.ConstructorOptions;
private _transactions;
private _transactionsRemoveListener;
private _closed;
constructor(options: IAnchored.ConstructorOptions);
/* Excluded from this release type: _getEmitter */
/** {@inheritDoc IAnchored.delete} */
delete(options?: ITransaction.OperationOptions): void;
/** {@inheritDoc IAnchored.getAnchorCoords} */
getAnchorCoords(): IRange.Coords;
/** {@inheritDoc IAnchored.getAnchorType} */
getAnchorType(): IAnchored.Type;
/** {@inheritDoc IAnchored.isProtected} */
isProtected(): boolean;
/** {@inheritDoc ITransaction.ITransactional.beginCommit} */
beginCommit(options?: string | ITransaction.OperationOptions): ITransaction;
protected _getState(): Readonly<STATE>;
protected _beginCommit(options?: string | ITransaction.OperationOptions): ITransaction;
protected _getTransactions(): ITransaction.IStore;
protected _updateState(updateState?: Partial<STATE>, //(prevState: STATE) => STATE,
options?: ITransaction.OperationOptions, events?: (keyof EVENTS)[]): this;
/* Excluded from this release type: _processContainerShift */
/* Excluded from this release type: _processBeforeCommitStart */
/* Excluded from this release type: _processStateChange */
/* Excluded from this release type: _processRestoreOrRevert */
/* Excluded from this release type: _processAnchorCoords */
/* Excluded from this release type: _processContainerLayout */
/* Excluded from this release type: _getDescription */
/* Excluded from this release type: _delete */
/* Excluded from this release type: _processContainerDelete */
/* Excluded from this release type: _processDelete */
/* Excluded from this release type: _processContainerProtection */
/** {@inheritDoc IListener.ISource.addListeners} */
addListeners(listeners: IListener.Callbacks<IAnchored, EVENTS>, options?: IListener.Options): IListener.Remove;
/** {@inheritDoc IAnchored.isClosed} */
isClosed(): boolean;
/* Excluded from this release type: _processClose */
/** {@inheritDoc IAnchored.close} */
close(): void;
/** {@inheritDoc IAnchored.isIAnchored} */
get isIAnchored(): true;
}
/* Excluded declaration from this release type: AbstractAnchored */
/**
* Abstract implement of `IModel`.
*/
declare abstract class AbstractModel<STATE extends AbstractModel.State = AbstractModel.State, JSON extends any = any, VIEW extends AbstractModel.CommitView = AbstractModel.CommitView, EVENTS extends IModel.Events = IModel.Events> implements IModel {
protected _emitter: ListenerEmitter<AbstractModel, EVENTS>;
protected _options: IModel.ConstructorOptions<JSON>;
protected _transactions: ITransaction.IStore;
protected _transactionsRemoveListener: IListener.Remove;
protected _closed: boolean;
constructor(options: IModel.ConstructorOptions<JSON>);
/* Excluded from this release type: _fromJSON */
isReadOnly(): boolean;
isDeleted(): boolean;
getType(): string;
get isIModel(): true;
/* Excluded from this release type: _processTransactionDone */
/* Excluded from this release type: _getDescription */
/* Excluded from this release type: _getState */
/* Excluded from this release type: _beginCommit */
/* Excluded from this release type: _getTransactions */
/* Excluded from this release type: _updateState */
/* Excluded from this release type: _getEmitter */
/* Excluded from this release type: _processInit */
/* Excluded from this release type: _processStateChange */
/* Excluded from this release type: _processRestoreOrRevert */
delete(options?: ITransaction.OperationOptions): void;
/* Excluded from this release type: _delete */
/* Excluded from this release type: _processOnContainerDeleted */
/* Excluded from this release type: _processDelete */
/* Excluded from this release type: _processOnContainerReadOnly */
/** {@inheritDoc IListener.ISource.addListeners} */
addListeners(listeners: IListener.Callbacks<IModel, EVENTS>, options?: IListener.Options): IListener.Remove;
/** {@inheritDoc ITransaction.ITransactional.beginCommit} */
beginCommit(options?: string | ITransaction.OperationOptions): ITransaction;
/** {@inheritDoc ITransaction.ITransactional.doBatch} */
doBatch<R>(callback: (commit: ITransaction.ICommit) => Promise<R> | R, options?: string | ITransaction.OperationOptions): Promise<R> | R;
/** {@inheritDoc ITransaction.ITransactional.isClosed} */
isClosed(): boolean;
/** {@inheritDoc ITransaction.ITransactional.close} */
close(): void;
}
/**
* Interfaces for creating `IAnchored`.
*
* @see
* ### **Interface**
*
* {@link AbstractModel}
*/
declare namespace AbstractModel {
interface State {
isDeleted: boolean;
}
interface CommitView {
}
}
declare abstract class AbstractTransaction implements ITransaction {
protected _states: Map<any, any>;
protected _description: string;
protected _meta: Record<string, string>;
protected _children: Set<AbstractTransaction>;
protected _depth: number;
protected _descriptions: string[];
protected _container: CommitContainer;
protected _closed: boolean;
constructor(container: CommitContainer, options: ITransaction.StoreOperationOptions);
/** {@inheritDoc ITransaction.getView} */
getView(): Record<any, string>;
/** {@inheritDoc ITransaction.getState} */
abstract getState<STATE = any>(model: any): STATE;
/** {@inheritDoc ITransaction.rollback} */
abstract rollback(): ITransaction;
/** {@inheritDoc ITransaction.getParent} */
abstract getParent(): ITransaction;
/** {@inheritDoc ITransaction.getId} */
abstract getId(): string;
/** {@inheritDoc ITransaction.getDepth} */
getDepth(): number;
/** {@inheritDoc ITransaction.getDescription} */
getDescription(): string;
/** {@inheritDoc ITransaction.getStates} */
getStates(): Map<any, any>;
/** {@inheritDoc ITransaction.beginTransaction} */
beginTransaction(options?: ITransaction.StoreOperationOptions, onClose?: ITransaction.CloseCallback): ITransaction;
/** {@inheritDoc ITransaction.updateState} */
updateState<STATE = any>(model: any, state: Readonly<Partial<STATE>> | ((prev: Readonly<STATE>) => Readonly<STATE>)): STATE;
/** {@inheritDoc ITransaction.commit} */
commit(options?: ITransaction.StoreOperationOptions): ITransaction;
/** {@inheritDoc ITransaction.isClose} */
isClose(): boolean;
protected _ensureOpen(): void;
_removeChild(child: AbstractTransaction): void;
protected _mergeStates(statesChild: Map<any, any>): Map<any, any>;
}
/**
* Collection of functions used for parsing Address string.
*
* Needed for OOXML import.
* @hidden
*/
export declare namespace AddressUtils {
const fastStringToCol: (address: string) => number;
const fastStringToCell: (address: string, reuse?: IRange.CellCoords) => IRange.CellCoords;
const fastStringToRange: (address: string, _reuse?: IRange.Coords) => IRange.Coords;
const rangeToString: RangeToString<IRange.Coords, IRange.CellCoords>;
const cellToString: CellToString<IRange.CellCoords>;
const normalizeA1ToR1C1: (formula: string, rowIndex: number, colIndex: number, tokens?: (string | IRange.FixableCellCoords)[]) => string;
const resolveRelativeToA1: (tokens: (string | IRange.CellCoords)[], rowIndex: number, colIndex: number) => string;
}
declare const angleToPoints: (angleDeg: number, rectBounds: Bounds) => {
x1: number;
y1: number;
x2: number;
y2: number;
};
declare namespace AutoFill_2 {
/**
* DateFill implements IAutoFill.Filler to work with Dates.
*/
class Date implements IAutoFill.Filler<JavaScriptDate> {
private _options;
constructor(options?: DateOptions);
/**
* Returns `true` if the value is a valid `Date`.
* @see
* {@link IAutoFill.Filler.canFill}
*/
canFill(value: any, _prev: JavaScriptDate): boolean;
/** {@inheritDoc IAutoFill.Filler.createFillAt} */
createFillAt(values: JavaScriptDate[], options?: DateOptions): IAutoFill.FillAt<JavaScriptDate>;
}
/**
* Adds additional fill options for Dates.
*/
interface DateOptions extends IAutoFill.Options {
/**
* If not provided the filler will attempt to determine.
* @defaultValue `The largest date unit found or day if one is not found.`
* // TODO - This doesn't support 'WeekDay'
*/
unit?: DateUnit;
}
/**
* LinearFill implements IAutoFill.Filler to work with numbers.
* TODO - implements stepValue/stepTo
*/
class Linear implements IAutoFill.Filler<number> {
private _options;
constructor(options?: IAutoFill.Options);
/**
* Returns `true` if the value is a valid number.
* @see
* {@link IAutoFill.Filler.canFill}
*/
canFill(value: any, _prev: number): boolean;
/** {@inheritDoc IAutoFill.Filler.createFillAt} */
createFillAt(values: readonly number[], options?: IAutoFill.Options): IAutoFill.FillAt<number> | null;
}
/**
* Ordinal implements IAutoFill.Filler to handles Strings that have a Integer value.
*/
class Ordinal implements IAutoFill.Filler<string> {
private _template;
/**
* Returns `true` if the value is a String that contains an Integer.
* @see
* {@link IAutoFill.Filler.canFill}
*/
canFill(value: any, prev: string): boolean;
/** {@inheritDoc IAutoFill.Filler.createFillAt} */
createFillAt(values: readonly string[], options?: IAutoFill.Options): IAutoFill.FillAt<string>;
}
/**
* The Copy Filler 'copies' values in a repeating pattern.
*
* @remarks
* This the default Filler when non is specified or no filler accepts the values
* being provided.
*/
class Copy implements IAutoFill.Filler<any> {
/**
* Always returns `true`.
* @see
* {@link IAutoFill.Filler.canFill}
*/
canFill(_value: any, _prev: any): boolean;
/** {@inheritDoc IAutoFill.Filler.createFillAt} */
createFillAt(values: readonly number[], _options?: IAutoFill.Options): IAutoFill.FillAt<number>;
}
/**
* ListFill implements IAutoFill.Filler to work with lists.
*/
interface ListOptions extends IAutoFill.Options {
/**
* A custom set of lists
*/
customLists?: readonly string[][];
}
/**
* The List Filler uses a list of strings in a repeating pattern.
*
* @remarks
* This the default Filler when non is specified or no filler accepts the values
* being provided.
*/
class List implements IAutoFill.Filler<string> {
private _lists;
private _map;
constructor(options?: ListOptions);
/**
* Always returns `true`.
* @see
* {@link IAutoFill.Filler.canFill}
*/
canFill(value: string, _prev: any): boolean;
/** {@inheritDoc IAutoFill.Filler.createFillAt} */
createFillAt(values: readonly string[], options?: IAutoFill.Options): IAutoFill.FillAt<string>;
}
/**
* A specialized `Filler` that aggregates multiple `Filler` instances to handle various data types
* during autofill operations.
*
* It delegates the filling process to the first `Filler` in its collection whose `canFill` method
* returns `true` for the given value, enabling seamless autofill functionality for mixed data types within a range.
*
* @remarks
* This filler will also handle blanks.
*/
class Composite<T = any> implements IAutoFill.Filler<T> {
private _fillers;
constructor(fillers: IAutoFill.Filler | IAutoFill.Filler[]);
/**
* Always returns `true`.
* @see
* {@link IAutoFill.Filler.canFill}
*/
canFill(_value: T, _prev: T): boolean;
/** {@inheritDoc IAutoFill.Filler.createFillAt} */
createFillAt(values: readonly T[], options?: IAutoFill.Options): IAutoFill.FillAt<T>;
}
/**
* Available Builtin Types.
*/
const Types: {
/**
* Default Fills.
* This attempts to fill use `Dates`, `Linear`, `Ordinal`, then `List`.
*/
readonly Series: Composite<any>;
/**
* Fills using individual days.
*/
readonly DateDays: Date;
/**
* Fills using months.
*/
readonly DateMonths: Date;
/**
* Fills using years.
*/
readonly DateYears: Date;
/**
* Fills with a repeating values.
*/
readonly Copy: Copy;
};
/**
* Simple methods that builds an array from a Filler.
*/
const fillTo: <T>(filler: IAutoFill.Filler, values: T[], to: number, options?: IAutoFill.Options) => T[];
}
export { AutoFill_2 as AutoFill }
declare enum AutoNumberingSchemeType {
/**
* Lowercase alphabetic character enclosed in parentheses. Example: (a), (b),
* (c), ...
*/
alphaLcParenBoth = 0,
/**
* Uppercase alphabetic character enclosed in parentheses. Example: (A), (B),
* (C), ...
*/
alphaUcParenBoth = 1,
/**
* Lowercase alphabetic character followed by a closing parenthesis. Example:
* a), b), c), ...
*/
alphaLcParenRight = 2,
/**
* Uppercase alphabetic character followed by a closing parenthesis. Example:
* A), B), C), ...
*/
alphaUcParenRight = 3,
/**
* Lowercase Latin character followed by a period. Example: a., b., c., ...
*/
alphaLcPeriod = 4,
/**
* Uppercase Latin character followed by a period. Example: A., B., C., ...
*/
alphaUcPeriod = 5,
/**
* Arabic numeral enclosed in parentheses. Example: (1), (2), (3), ...
*/
arabicParenBoth = 6,
/**
* Arabic numeral followed by a closing parenthesis. Example: 1), 2), 3), ...
*/
arabicParenRight = 7,
/**
* Arabic numeral followed by a period. Example: 1., 2., 3., ...
*/
arabicPeriod = 8,
/**
* Arabic numeral. Example: 1, 2, 3, ...
*/
arabicPlain = 9,
/**
* Lowercase Roman numeral enclosed in parentheses. Example: (i), (ii), (iii),
* ...
*/
romanLcParenBoth = 10,
/**
* Uppercase Roman numeral enclosed in parentheses. Example: (I), (II), (III),
* ...
*/
romanUcParenBoth = 11,
/**
* Lowercase Roman numeral followed by a closing parenthesis. Example: i), ii),
* iii), ...
*/
romanLcParenRight = 12,
/**
* Uppercase Roman numeral followed by a closing parenthesis. Example: I), II),
* III), ....
*/
romanUcParenRight = 13,
/**
* Lowercase Roman numeral followed by a period. Example: i., ii., iii., ...
*/
romanLcPeriod = 14,
/**
* Uppercase Roman numeral followed by a period. Example: I., II., III., ...
*/
romanUcPeriod = 15,
/**
* Double byte circle numbers.
*/
circleNumDbPlain = 16,
/**
* Wingdings black circle numbers.
*/
circleNumWdBlackPlain = 17,
/**
* Wingdings white circle numbers.
*/
circleNumWdWhitePlain = 18,
/**
* Double-byte Arabic numbers with double-byte period.
*/
arabicDbPeriod = 19,
/**
* Double-byte Arabic numbers.
*/
arabicDbPlain = 20,
/**
* Simplified Chinese with single-byte period.
*/
ea1ChsPeriod = 21,
/**
* Simplified Chinese.
*/
ea1ChsPlain = 22,
/**
* Traditional Chinese with single-byte period.
*/
ea1ChtPeriod = 23,
/**
* Traditional Chinese.
*/
ea1ChtPlain = 24,
/**
* Japanese with double-byte period.
*/
ea1JpnChsDbPeriod = 25,
/**
* Japanese/Korean.
*/
ea1JpnKorPlain = 26,
/**
* Japanese/Korean with single-byte period.
*/
ea1JpnKorPeriod = 27,
/**
* Bidi Arabic 1 (AraAlpha) with ANSI minus symbol.
*/
arabic1Minus = 28,
/**
* Bidi Arabic 2 (AraAbjad) with ANSI minus symbol.
*/
arabic2Minus = 29,
/**
* Bidi Hebrew 2 with ANSI minus symbol.
*/
hebrew2Minus = 30,
/**
* Thai alphabetic character followed by a period.
*/
thaiAlphaPeriod = 31,
/**
* Thai alphabetic character followed by a closing parenthesis.
*/
thaiAlphaParenRight = 32,
/**
* Thai alphabetic character enclosed by parentheses.
*/
thaiAlphaParenBoth = 33,
/**
* Thai numeral followed by a period.
*/
thaiNumPeriod = 34,
/**
* Thai numeral followed by a closing parenthesis.
*/
thaiNumParenRight = 35,
/**
* Thai numeral enclosed in parentheses.
*/
thaiNumParenBoth = 36,
/**
* Hindi alphabetic character followed by a period.
*/
hindiAlphaPeriod = 37,
/**
* Hindi numeric character followed by a period.
*/
hindiNumPeriod = 38,
/**
* Hindi numeric character followed by a closing parenthesis.
*/
hindiNumParenRight = 39,
/**
* Hindi alphabetic character followed by a period.
*/
hindiAlpha1Period = 40
}
/**
* We need to keep track of before/after for the undo stack when not part of the transaction.
*/
declare interface BeforeAfterRange {
beforeState: ICellRangesListenerEntry;
afterState: ICellRangesListenerEntry;
}
/**
* Points are return tl, tr, br, bl
*
* @param bounds {@link Bounds}
* @returns A array of points [tl, tr, br, bl]
*/
declare const boundsToPoints: (bounds: Bounds) => Point[];
declare interface CacheSearchRunData<T = any> {
runs: readonly ITypes.RunCoordValue<T>[];
run: ITypes.RunCoordValue<T | null>;
index: number;
}
declare interface CalcNode {
block: FormulaBlockEntry;
colIndex: number;
rowIndex: number;
cycleId: number;
markId: number;
inDegree: number;
dependents: any[];
inputs: any[];
precedents: (PrecedentCalcCache | FormulaError.Known)[];
dynamic: any[];
cachedValue: any;
removed: boolean;
/**
* Indicates if the pending is in the pending spatial (to avoid lookup)
*/
pending: boolean;
/**
* Indicates the pending is waiting on a precedent to resolve.
*/
pendingPrecedents: boolean;
/**
* Indicates the pending is full filled and waiting for the next cycle to resolve.
*/
pendingResolved: boolean;
pendingPromise: Promise<any> | null;
/**
* The state is a bit mask with transient states.
* The CalcNode is reused across cycles and cloned records for performance.
* To ensure that it is correct the cycleId id must be consulted.
*/
state: number;
error: FormulaError.Known;
}
/**
* Implementation for {@link ICalculation}.
*/
export declare class Calculation extends AbstractModel<State_2, ICalculation.JSON, CommitView, ICalculation.IListeners> implements ICalculation {
protected _context: CalculationContext;
protected _scope: ICalcGraphScope;
protected _functions: IFunctionCollection;
protected _runtime: IRuntime;
protected _formulaParser: IFormulaParser;
protected _emitter: ListenerEmitter<Calculation, ICalculation.IListeners>;
protected _status: ICalculation.Status;
protected _statusTransition: Promise<void> | null;
constructor(options?: Calculation.ConstructorOptions);
protected _getContext(): CalculationContext;
protected _getScope(): ICalcGraphScope;
/** @inheritdoc ICalculation.start */
start(): Promise<void>;
protected _createGraph(options: ICalcGraph.ConstructorOptions): ICalcGraph;
/** @inheritdoc ICalculation.stop */
stop(): Promise<void>;
/** @inheritdoc ICalculation.getStatus */
getStatus(): ICalculation.Status;
/** @inheritdoc ICalculation.getFunctions */
getFunctions(): IFunctionCollection;
/** @inheritdoc IFormulaContext.getRuntime */
getRuntime(): IRuntime;
protected _checkReady(): void;
protected _statusMessage(): string;
}
/**
* Interfaces for creating `Calculation` items.
*
* @see
* ### **Interface**
*
* {@link Calculation}
*/
export declare namespace Calculation {
/**
* Options for creating an ICalculation.
*/
export interface ConstructorOptions extends ICalculation.ConstructorOptions, IModel.ConstructorOptions<ICalculation.JSON> {
}
}
declare class CalculationContext implements IFormulaContext {
protected _calcScope: ICalcGraphScope;
protected _instanceScope: any;
protected _options: ICalculation.ConstructorOptions;
protected _runtime: IRuntime;
protected _builtInFunctions: ReadonlyMap<string, IFunction>;
protected _getFunction: (name: string) => IFunction;
protected _isColumn: boolean;
constructor(options?: ICalculation.ConstructorOptions, isColumn?: boolean);
/** @hidden */
_setInstanceScope(instanceScope: any): void;
/** @hidden */
_initialize(): Promise<{
builtInFunctions: ReadonlyMap<string, IFunction>;
calcScope?: ICalcGraphScope;
}>;
/**
* Returns a builtin map of built-in functions.
*/
getBuiltInFunctions(): ReadonlyMap<string, IFunction>;
/** @inheritdoc IFormulaContext.getFunction */
getFunction(name: string): IFunction;
/** @inheritdoc IFormulaContext.getNumberFormat */
getNumberFormat(formatText: string, value: Scalar): string;
/** @inheritdoc IFormulaContext.getEntireCoords */
getEntireCoords(): IRange.Coords;
/** @inheritdoc IFormulaContext.getFormulaAt */
getFormulaAt(row: number, column: number): string | null;
/** @inheritdoc IFormulaContext.markVolatile */
markVolatile(): void;
/** @inheritdoc IFormulaContext.formatResults */
formatResults(numFmt: string): void;
/** @inheritdoc IFormulaContext.getSheetIndex */
getSheetIndex(sheetName?: string): number;
/** @inheritdoc IFormulaContext.getSheetCount */
getSheetCount(): number;
/** @inheritdoc IFormulaContext.isValidDate */
isValidDate(value: any): boolean;
/** @inheritdoc IFormulaContext.fromOADate */
fromOADate(oaDate: number): Date;
/** @inheritdoc IFormulaContext.toOADate */
toOADate(date: Date): number;
protected _fromTuples(boundedTuples: Tuple.BoundedTuples<Scalar>, type?: ScalarType, isLiteral?: boolean): IRange;
/** @inheritdoc IFormulaContext.getValueAt */
getValueAt(rowIndex: number, colIndex: number): Scalar | null;
/** @inheritdoc IFormulaContext.getRange */
getSpillAt(rowIndex: number, colIndex: number): IReferenceRange | null;
/** @inheritdoc IFormulaContext.getRange */
getRange(value: Scalar | Scalar[][], isLiteral?: boolean): IRange;
/** @inheritdoc IFormulaContext.getPosition */
getPosition(): IRange.CellCoords;
/** @inheritdoc IFormulaContext.getReference */
getReference(coords: IRange.Coords | string, r1c1?: boolean): IReferenceRange;
/** @inheritdoc IFormulaContext.getAddress */
getAddress(coords?: Readonly<IRange.FixableCoords | IRange.FixableCellCoords>, r1c1?: boolean): string;
/** @inheritdoc IFormulaContext.parseAsDateTime */
parseAsDateTime(text: string, requireDate?: boolean): number | null;
/** @inheritdoc IFormulaContext.getRuntime */
getRuntime(): IRuntime;
get [Symbol.toStringTag](): string;
toString(): string;
}
/**
* Converts a camelCase string to snake_case.
*
* @param str The camelCase string to convert.
* @returns The string converted to snake_case.
*
* @example
* ```ts
* camelToSnake('camelCaseString'); // Returns 'camel_case_string'
* ```
*/
declare const camelToSnake: (str: string) => string;
/**
* Capitalizes the first character of a string and optionally lowercases the rest of the string.
*
* @param str The input string to be processed.
* @param lowerCaseRest A boolean flag indicating whether to convert the rest of the string to lowercase.
* If `true`, the remaining characters (after the first) will be converted to lowercase.
* If `false`, the remaining characters will remain unchanged.
*
* @returns A new string with the first character capitalized and the rest lowercased if the `lowerCaseRest` flag is `true`.
* If the `lowerCaseRest` flag is `false`, only the first character is capitalized, and the rest of the string remains unchanged.
*
* @example
* ```
* capitalize("hello"); // Returns "Hello"
* capitalize("hello", true); // Returns "Hello"
* capitalize("HELLO", true); // Returns "Hello"
* capitalize("123abc", true); // Returns "123abc"
* capitalize("", true); // Returns ""
* ```
*/
declare const capitalize: (str: string, lowerCaseRest?: boolean) => string;
/**
* Note - By using optional keys as a way to detect default values we are creating mono polymorphic objects. (perform issue in V8).
* Revisit and store all keys as a single type.
* 1. Create a 'default' state. We will need an isEmpty method to compare all value for pruning. (Probably just )
* 2. Only save values that are different than the default state
*/
declare interface CellHeaderState {
sz?: number;
csz?: boolean;
h?: boolean;
s?: IStyle;
cs?: boolean;
}
declare namespace CellState {
/* Excluded from this release type: TypeAndValue */
/**
* Entries iterators are arrays of fixed length 5.
*/
type Entry = [
coords: IRange.CellCoords,
v: Scalar,
rs: RangeState.Intersection,
prev: IRange.CellCoords,
next: IRange.CellCoords
];
/**
* Shorthand type.
*/
type IteratorResult = WellKnownIteratorResult<CellState.Entry>;
/**
* Shorthand type.
*/
type Iterator = WellKnownIterator<CellState.Entry, CellState.Entry, IRange.CellCoords>;
/* Excluded from this release type: IteratorOptions */
}
declare type CellToString<C extends IRange.CellCoords = IRange.CellCoords> = (cell: C) => string;
/**
* Return the absolute center of the bounds.
*/
declare const centerPoint: (bounds: Bounds) => Point;
/**
* Trims a string to a specified maximum length and adds an ellipsis (`…`) if the string exceeds the limit.
*
* @param str The string to trim.
* @param maxLength The maximum length of the string before truncation (default is 36).
* @returns The truncated string with an ellipsis if it exceeds the specified length.
*
* @example
* ```ts
* clampString('This is a long string', 10); // Returns 'This is a …'
* ```
*/
declare const clampString: (str: string, maxLength?: number) => string;
/**
* Takes an an inner un-rotated dimension and an outer un-rotated dimension and then will return
* an un-rotated rectangle that if rotated will fit inside the outer rectangle.
*/
declare const clipToOuterRect: (dimInner: Dimensions, dimOuter: Dimensions, rotation?: number) => Dimensions;
/**
* Capabilities for working with {@link IColor | colors}.
*
* Advanced color customization and compatibility with CSS and Office color schemes.
*
* Key features include:
* - Accessing a collection of built-in colors (Named, Scheme, Index).
* - Creating customized colors with color adjustments.
* - Defining and and converting between different color models (RGB, HEX, HSL).
*
* @see
* {@link IColor}
*/
export declare class Color implements IColor {
private _private;
constructor(value: string | IColor | IColor.Definition, schemeLookup?: IColor.SchemeLookup, indexedLookup?: IColor.IndexedLookup, last?: ColorSpace.RGBA);
private _parse;
private _forceDark;
private _resolve;
/**
* @hidden
* TODO - Rationalize this. Do we want a constructor a static parse?
*/
static parse(input: string | IColor, schemeLookup?: IColor.SchemeLookup, indexedLookup?: IColor.IndexedLookup, last?: ColorSpace.RGBA): IColor | null;
/**
* Returns the default color scheme lookup that Colors will use if none is provided.
*/
static getDefaultSchemeLookup(): IColor.SchemeLookup;
/** {@inheritDoc IColor.isEqual} */
isEqual(other: any): boolean;
/** {@inheritDoc IColor.getVal} */
getVal(): string;
/** {@inheritDoc IColor.getAdjustments} */
getAdjustments(): readonly IColor.Adjustment[];
/** {@inheritDoc IColor.adjust} */
adjust(adjustments: IColor.Adjustment[]): IColor;
/** {@inheritDoc IColor.getType} */
getType(): IColor.Type;
/** {@inheritDoc IColor.toCSS} */
toCSS(darkMode?: boolean, alpha?: boolean): string;
/** {@inheritDoc IColor.toRGBA} */
toRGBA(darkMode?: boolean): IColor.ISpace.RGBA;
/** {@inheritDoc IColor.toHSLA} */
toHSLA(darkMode?: boolean): IColor.ISpace.HSLA;
/** {@inheritDoc IColor.toHex} */
toHex(darkMode?: boolean): IColor.ISpace.HEX;
/** {@inheritDoc IColor.toBlackOrWhite} */
toBlackOrWhite(darkMode?: boolean, threshold?: number): IColor;
get [Symbol.toStringTag](): string;
/** {@inheritDoc IColor.toString} */
toString(): string;
/** {@inheritDoc IColor.isIColor} */
get isIColor(): true;
}
/**
* Color definitions available in various ColorSpaces.
*/
declare namespace ColorSpace {
/**
* A color in the Red, Green, Blue color space.
*/
class RGBA {
protected _private: {
red: number;
green: number;
blue: number;
alpha: number;
};
constructor(red: number, green: number, blue: number, alpha?: number);
get red(): number;
get green(): number;
get blue(): number;
get alpha(): number;
toString(alpha?: boolean): string;
isEqual(other: ColorSpace.RGBA): boolean;
isAlmostEqual(other: ColorSpace.RGBA): boolean;
}
/**
* A color in the Hue, Saturation, Luminosity color space.
*/
class HSLA {
private _private;
constructor(hue: number, sat: number, lum: number, alpha: number);
get hue(): number;
get sat(): number;
get lum(): number;
get alpha(): number;
toString(alpha?: boolean): string;
isEqual(other: ColorSpace.HSLA): boolean;
isAlmostEqual(other: ColorSpace.HSLA): boolean;
}
/**
* A color (Red, Green, Blue) encoded in hexadecimal.
*/
class HEX extends ColorSpace.RGBA {
toString(alpha?: boolean): string;
}
}
declare interface CommitContainer {
record: CommitRecord;
commit: ITransaction.ICommit;
}
declare interface CommitEvents {
address?: Map<string, RangesListener>;
data?: IRange.Coords[];
dataListeners?: Map<string, RangesListener>;
}
declare interface CommitRecord {
id?: string;
description?: string;
meta?: Record<string, string>;
timestamp: number;
author?: any;
states?: Map<any, any>;
operation?: ITransaction.Operation<any>;
viewBefore?: Record<string, any>;
viewAfter?: Record<string, any>;
previousId?: string;
version: number;
}
declare interface CommitView extends AbstractModel.CommitView {
}
/* Excluded from this release type: CommitView_2 */
declare interface CommitView_3 {
initial?: boolean;
view?: ISheetView;
selection?: Partial<IRangeSelection.Coords>;
selectOptions?: boolean | ICellRange.SelectOptions;
movableSelection?: readonly IMovable[];
ranges?: readonly IRange.FixableCoords[];
events?: CommitEvents;
formulas?: readonly IRange.FixableCoords[];
/**
* Special case for range listeners that monitored a remove.
*/
merges?: readonly IRange.FixableCoords[];
listeners?: Map<number, BeforeAfterRange>;
/** If `true` then don't do protection check. (For example load or range listeners) */
skipProtectionCheck?: boolean;
/**
* We update values (cache, potentially styling, as a result of calculations)
*/
calculationSideEffect?: boolean;
}
declare function concatModifiedRuns<T>(parts: ModifiedRuns<T>): ITypes.RunCoordValue<T>[];
declare class ConditionalEntry implements IProperties.ICellRanged<IStyle.Properties>, ISpatialMap.IUpdatableEntry {
protected _c: IRange.Coords;
protected _m: IConditionalFormat;
constructor(coords: IRange.Coords, model: IConditionalFormat);
getModel(): IConditionalFormat;
/** {@inheritDoc IProperties.ICellRanged.getCoords} */
getCoords(): IRange.Coords;
/** {@inheritDoc IProperties.ICellRanged.getPropertiesAt} */
getPropertiesAt(rowIndex: number, colIndex: number, value: Scalar): Readonly<IStyle.Properties>;
/** {@inheritDoc ISpatialMap.IUpdatableEntry.getSplit} */
getSplit(coords: readonly [IRange.Coords, IRange.Coords]): [this, this] | undefined;
}
/**
* Used for identifying contiguously filled ranges.
*/
declare class ContentfulEntry {
private _c;
private _o;
constructor(coords: IRange.Coords, orientation: IRange.Orientation);
getCoords(): IRange.Coords;
getOrientation(): IRange.Orientation;
/** {@inheritDoc ISpatialMap.IUpdatableEntry.getShifted} */
getShifted(options: ISpatialMap.ShiftDetails<this>): ISpatialMap.Entry<this>;
/** {@inheritDoc ISpatialMap.IUpdatableEntry.getMerged} */
getMerged(_other: this, coords: IRange.Coords, _orientation: IRange.Orientation): this;
/** {@inheritDoc ISpatialMap.IUpdatableEntry.getSplit} */
getSplit(coords: [IRange.Coords, IRange.Coords], _orientation: IRange.Orientation): [this, this] | undefined;
getState(): IRange.Coords;
}
/**
* Counts the number of decimal places in a numeric string.
*
* @param input The string representation of a number.
* @returns The number of decimal places. Returns 0 if there are no decimal places.
*
* @example
* ```ts
* countDecimals('123.456'); // Returns 3
* countDecimals('123'); // Returns 0
* ```
*/
declare const countDecimals: (input: string) => number;
/* Excluded from this release type: CreateCellHeaderCallback */
/**
* Create an invalid range.
*/
declare function createRangeInvalidRef(header: ISheetHeader): ICellHeaderRange;
/**
* Create runs from selection.
*/
declare const createRunsFromSelection: (header: ISheetHeader, selection: IRangeSelection.Coords, maxRange: IRange.Coords) => ITypes.RunCoordValue<ISheetHeader.SelectedRun>[];
declare const createSearchRunCache: <T = any>(runs: readonly ITypes.RunCoordValue<T>[]) => CacheSearchRunData<T>;
declare function cullRuns<T>(runs: ITypes.RunCoordValue<T>[], options?: CullRunsOptions<T>): ModifiedRuns<T>;
declare interface CullRunsOptions<T> {
startOffset?: number;
endOffset?: number;
/**
* Used to determine if a value should removed. If data is null or undefined it will also be removed.
* By default an empty object will not be.
*/
cull?(value: T, min: number, max: number): boolean;
}
declare const DateUnit: {
readonly Day: "d";
readonly Month: "m";
readonly Year: "y";
};
declare type DateUnit = typeof DateUnit[keyof typeof DateUnit];
declare const deepCull: (value: any, _min: number, _max: number) => boolean;
declare const deepUpdate: (prevValue: any | null, newValue: any | null) => any | null;
declare class DefaultProtection<T, P extends IProtection.Properties, J extends IProtection.JSON> implements IProtection<T, P, J> {
protected _emitter: ListenerEmitter<this, IProtection.IListeners>;
protected _isPaused: boolean;
protected _password: Partial<IProtection.EncryptedPassword>;
protected _identities: IProtection.IdentityProvider[];
protected _properties: Partial<P>;
protected _isReadOnly: boolean;
constructor(json?: J, isReadOnly?: boolean);
/** {@inheritDoc IProtection.lock} */
lock(properties?: Partial<P>, password?: string, algorithm?: string, spinCount?: number): Promise<IProtection<T, P, J>>;
/** {@inheritDoc IProtection.unlock} */
unlock(password?: string): Promise<IProtection<T, P, J>>;
/** {@inheritDoc IProtection.checkPassword} */
checkPassword(password?: string): Promise<boolean>;
/** {@inheritDoc IProtection.hasPassword} */
hasPassword(): boolean;
/** {@inheritDoc IProtection.pause} */
pause(password?: string): Promise<IProtection<T, P, J>>;
/** {@inheritDoc IProtection.resume} */
resume(): IProtection<T, P, J>;
/** {@inheritDoc IProtection.isPaused} */
isPaused(): boolean;
/** {@inheritDoc IProtection.isLocked} */
isLocked(): boolean;
/** {@inheritDoc IProtection.isReadOnly} */
isReadOnly(): boolean;
protected _validatePassword(password?: string): Promise<boolean>;
getProperties(): Partial<P>;
protected _isPropertyAllowed(property: keyof P): boolean;
protected _updateProperties(properties: IProtection.Properties): void;
protected _clearProperties(): void;
/** {@inheritDoc IListener.ISource.addListeners} */
addListeners(listeners: IProtection.IListeners, options?: IListener.Options): IListener.Remove;
fromJSON(json: J): void;
protected _fromJSON(_json: J | null): void;
protected _toJSON(json: Partial<J>): Partial<J>;
/** {@inheritDoc IWorkbookProtection.toJSON} */
toJSON(): J;
}
declare const DefaultUnQuoteRegEx: RegExp;
declare interface Entry<SOURCE, EVENTS> {
remove?: IListener.Remove;
listeners: IListener.Callbacks<SOURCE, EVENTS>;
}
declare type EntrySet<SOURCE = any, EVENTS = any> = Set<Entry<SOURCE, EVENTS>>;
/**
* Iterate over a collection of overlapping RangeCoord.
*
* This will iterator over CellCoords or RangeCoords.
*/
declare type ESIterator<T, TReturn = any, TNext = undefined> = Iterator<T, TReturn, TNext>;
/**
* Implements {@link ReferenceableClipboard.ReferenceItem} by creating a {@link ICellRange.ISnapshot} from
* {@link ReferenceableClipboard.NativeItems}.
*
* @remarks
* **IMPORTANT** Before this api can be used the async {@link parse} methods needs to be called and resolved.
* @see
* {@link parse}
*/
export declare class ExternalRangeClipboardItem implements ReferenceableClipboard.ReferenceItem<ICellRange.ISnapshot> {
private _native;
private _markOptions;
private _styles;
private _isDate1904;
private _snapshot;
private _parsed;
constructor(native: ReferenceableClipboard.NativeItems, markOptions?: ICellRange.CopyOptions, styles?: IStyleCollection, date1904?: boolean);
getItemType(): string;
isCut(): boolean;
toText(): string;
toHtml(): string;
toImage(): Blob;
getItem(): ICellRange.ISnapshot<ISheet>;
/**
* Required to be called before getItem().
* @remarks
* This is required because the ExternalClipboard lazy loads the parsing library.
*/
parse(): Promise<boolean>;
get isClipboardItem(): true;
}
/**
* Tries to find a font that match the fontName exactly. If this is not found then it will use the fallback
* options if provided. If there is no font and no font fallback it will return null.
* @param fontName The font name to find
* @returns The FontHandle
*/
declare const findBestMatch: (fontName: string, options?: FindBestMatchOptions) => FontHandle;
declare interface FindBestMatchOptions {
/**
* Defaults to false
*/
bold?: boolean;
/**
* Defaults to false
*/
italic?: boolean;
/**
* A list of font names or generic font family
*/
fallbacks?: string[];
panose?: string;
}
/**
* These assume a results from {@link indexHeaderSizes} are used. No error handling is performed.
* sizes.length > 0. All values must be contiguous. offset must be >= 0 && offset <= size[size.length].maxOffset.
* @remarks
* If the current index is hidden it will return the offset before the value
* @param sizes
* @param offset
* @returns the index for the given offset.
*/
declare const findIndex: (sizes: RunningHeaderSize[], offset: number, defaultSize: number) => number;
declare const findIntersectMath: (p1: Point, p2: Point, min: number, max: number) => {
min: number;
max: number;
};
/**
* Looks for a run going in a certain direction. If there isn't a run for this it will look for the next
* run. If you only want the run if it is found then use {@link findRun}.
*
* @param runs An array of Run or RunCoords.
* @param index The index that will be >= min && <= max.
* @param findGreater - *`default`* `true` If true will search greater if false lesser.
* @returns The index for the next run or -1 if no run was found.
*/
declare const findNextRunOffset: <T = any>(runs: ITypes.RunCoordValue<T>[], index: number, findGreater?: boolean) => number;
/**
* These assume a results from {@link indexHeaderSizes} is used. No error handling is performed.
* All size runs must be contiguous.
* @param sizes
* @param index
* @returns The offset for the given index.
*/
declare const findOffset: (sizes: RunningHeaderSize[], index: number, defaultSize: number) => number;
declare const findRun: <T>(runs: ITypes.RunCoordValue<T>[], index: number) => ITypes.RunCoordValue<T> | null;
/**
* Finds the visibleIndex for a given absolute index.
* Returns a RunCoords. This can be used to determine if an index is hidden
* If it's hidden it will return a range of 1 with a value before the offset and after.
* If it's visible then it will return a range of 0 with the min and max that exactly match the offset.
* @remarks
* If this is on the edge of the bounds this will return a +/- 1 the max bounds.
* @param index The absolute index
*/
declare const findRunningHiddenRuns: (sizes: RunningHeaderSize[], index: number, maxIndex?: number) => RunCoords;
/**
* Finds the total length between to points account for hidden spans.
* No validation is done.
*/
declare const findRunningSpanLength: (runs: RunningHeaderSize[], from: number, to: number) => number;
/**
* Will try to find a valid text value from a template by incrementing a last number.
*
* @param template The string to use for a baseline for generating new text values.
* @param isValidName A callback for validating the current text.
* @returns A string for the first valid text.
*/
declare const findValidTextValue: (template: string, isValidName: (candidate: string) => boolean, maxIncrement?: number) => string;
declare interface FontHandle {
fontRef: IFont.IFontFace;
loaded: boolean;
}
declare class FormulaBlockEntry implements ISpatialMap.IUpdatableEntry<FormulaBlockEntry> {
ref: IRange.Coords;
formula: ICalcGraph.IFormulaBlock;
calcs: CalcNode[][];
/**
* If a calcs is provided it is assumed to be shallow cloned or ok to modify
*/
constructor(coords: IRange.Coords, formula: ICalcGraph.IFormulaBlock, calcs?: CalcNode[][]);
toJSON(): [coords: string, text: string];
getCoords(): IRange.Coords;
/** {@inheritDoc ISpatialMap.IUpdatableEntry.getShifted} */
getShifted(options: ISpatialMap.ShiftDetails<this>): ISpatialMap.Entry<this>;
/**
* Creates a new calculation entry with once precedent updated.
* @param precedent
* @param index
*/
setReferenceAt(index: number, reference: IRange.FixableCoords): this;
/** {@inheritDoc ISpatialMap.IUpdatableEntry.getMerged} */
getMerged(other: this, coords: IRange.Coords, orientation: IRange.Orientation): this | undefined;
/** {@inheritDoc ISpatialMap.IUpdatableEntry.getSplit} */
getSplit(coords: [IRange.Coords, IRange.Coords], orientation: IRange.Orientation, offset: number): [this, this] | undefined;
/** {@inheritDoc ISpatialMap.IUpdatableEntry.copyTo} */
copyTo(destination: IRange.Coords, options?: ISpatialMap.CopyOptions): this;
/** {@inheritDoc ISpatialMap.IUpdatableEntry.canTile} */
canTile(_destination: IRange.Coords, _options?: ISpatialMap.CopyOptions): boolean;
/** {@inheritDoc ISpatialMap.IUpdatableEntry.getSplit} */
onRemove?(entry: ISpatialMap.Entry<FormulaBlockEntry>): void;
}
/**
* Used by Sheet to track formula strings (but not the calculation results)
*/
declare class FormulaEntry {
private _c;
private _tokens;
private _references;
constructor(coords: IRange.Coords, tokens?: ICalculation.FormulaToken[], references?: readonly (IRange.FixableCoords | string | FormulaError.Known)[]);
getFormulaTextAt(row: number, column: number, r1c1?: boolean): string;
getTokensAt(row: number, column: number, evalIndex?: number): readonly ICalculation.FormulaToken[];
getReferencesAt(row: number, column: number): readonly (IRange.FixableCoords | string | FormulaError.Known)[];
toJSON(): [string, string];
getCoords(): IRange.Coords;
}
export declare namespace GeomUtils {
export {
unionBounds,
centerPoint,
boundsToPoints,
minBoundingRect,
rotatePoints,
clipToOuterRect,
findIntersectMath,
angleToPoints
}
}
/**
* Extracts the base name (file name without extension) from a file path.
*
* @param path The file path from which to extract the base name.
* @param shouldCapitalize A boolean flag indicating whether to capitalize the base name. Defaults to `false`.
*
* @returns The base name of the file. The base name will be capitalized if `shouldCapitalize` is `true`.
*
* @example
* ```
* getBaseName("example.txt"); // Returns "Example"
* getBaseName("/path/to/file.jpg"); // Returns "File"
* getBaseName("file_without_extension", false); // Returns "file_without_extension"
* getBaseName("", false); // Returns ""
* ```
*/
declare const getBaseName: (path: string, shouldCapitalize?: boolean) => string;
/**
* Extracts the file extension from a file path.
*
* @param path The file path from which to extract the file extension.
*
* @returns The file extension in lowercase. Returns an empty string if the path is invalid or has no extension.
*
* @example
* ```
* getFileNameExtension("example.txt"); // Returns "txt"
* getFileNameExtension("/path/to/file.jpg"); // Returns "jpg"
* getFileNameExtension("no_extension"); // Returns ""
* getFileNameExtension(""); // Returns ""
* ```
*/
declare const getFileNameExtension: (path: string) => string;
declare function getFontList(): readonly FontHandle[];
declare interface GetRangeEntriesOptions<T = any, E = any> {
excludeHidden?: boolean | IRange.Orientation;
fullyContained?: boolean;
onEntry?: (value: E, entry: ISpatialMap.Entry<T>) => T | void;
noCache?: boolean;
s