@sheetwrite/coreinterface
Host callback that asynchronously loads cancellable rectangular pages.
Examples
return { }; },};See also
Members 2
capabilities
getRows Loads the requested rows and columns; implementations should stop work when its signal aborts.
Declaration
View full TypeScript declaration
export interface DataSource {}Referenced by
Workspace packages depending on @sheetwrite/core
@sheetwrite/benchdependency@sheetwrite/docs-startdependency@sheetwrite/reactdependency@sheetwrite/sveltedependency@sheetwrite/vuedependency@sheetwrite/xlsxdependency
Public exports naming DataSource
GridOptions@sheetwrite/corelegacyFullWidthDataSource@sheetwrite/coreSheetwriteGridProps@sheetwrite/reactSheetwriteGridProps@sheetwrite/vue
interface DataSourceinterface DataSourceinterface DataSourceHost callback that asynchronously loads cancellable rectangular pages.@example import type { DataSource, RowData } from "@sheetwrite/core"; const rows: RowData[] = [{ amount: 12 }, { amount: 18 }]; const datasource: DataSource = { capabilities: { protocol: 2, columns: "windowed" }, async getRows(request) { request.signal.throwIfAborted(); return { protocol: 2, start: request.start, columns: request.columns, rows: rows.slice(request.start, request.end).map((row) => Object.fromEntries(request.columns.flatMap((band) => band.keys.map((key) => [key, row[key] ?? null])))), }; }, };@see GridOptions.datasource *@see DataSourceRequestAPI reference →type RowData = {
[x: string]: DataCell;
}type RowData = {
[x: string]: DataCell;
};type RowData = {
[x: string]: DataCell;
};Object-shaped datasource row keyed by workbook column keys.API reference →const rows: RowData[]const rows: RowData[]const rows: RowData[]end-exclusive row rangeAPI reference →amount: numberlet amount: numberlet amount: numberconst datasource: DataSourceconst datasource: DataSourceconst datasource: DataSourceLazy row provider requested for visible windows; use instead of eager data.API reference →DataSource.capabilities: DataSourceCapabilitiesinterface DataSource {
capabilities: DataSourceCapabilities;
}interface DataSource {
capabilities: DataSourceCapabilities;
}DataSourceCapabilities.protocol: 2interface DataSourceCapabilities {
protocol: 2;
}interface DataSourceCapabilities {
protocol: 2;
}Paging contract version.API reference →DataSourceCapabilities.columns: "windowed" | "full-width"interface DataSourceCapabilities {
columns: "windowed" | "full-width";
}interface DataSourceCapabilities {
columns:
"windowed" | "full-width";
}Exact column runs represented by every returned row.API reference →DataSource.getRows(request: DataSourceRequest): Promise<DataSourcePage>DataSource.getRows(request: DataSourceRequest): Promise<DataSourcePage>DataSource.getRows(request: DataSourceRequest): Promise<DataSourcePage>Loads the requested rows and columns; implementations should stop work when its signal aborts.API reference →request: DataSourceRequestlet request: DataSourceRequestlet request: DataSourceRequestAPI reference →DataSourceRequest.signal: AbortSignalinterface DataSourceRequest {
signal: AbortSignal;
}interface DataSourceRequest {
signal: AbortSignal;
}Abort before or between bounded codec operations.API reference →AbortSignal.throwIfAborted(): void (+1 overload)AbortSignal.throwIfAborted(): void (+1 overload)AbortSignal.throwIfAborted(): void (+1 overload)The throwIfAborted() method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing. MDN ReferenceDataSourcePage.protocol: 2interface DataSourcePage {
protocol: 2;
}interface DataSourcePage {
protocol: 2;
}Paging contract version.API reference →DataSourcePage.start: numberinterface DataSourcePage {
start: number;
}interface DataSourcePage {
start: number;
}Inclusive row index of the first returned row.API reference →DataSourceRequest.start: numberinterface DataSourceRequest {
start: number;
}interface DataSourceRequest {
start: number;
}Inclusive row index.API reference →DataSourcePage.columns: readonly DataSourceColumnBand[]interface DataSourcePage {
columns: readonly DataSourceColumnBand[];
}interface DataSourcePage {
columns: readonly DataSourceColumnBand[];
}Exact column runs represented by every returned row.API reference →DataSourceRequest.columns: readonly DataSourceColumnBand[]interface DataSourceRequest {
columns: readonly DataSourceColumnBand[];
}interface DataSourceRequest {
columns: readonly DataSourceColumnBand[];
}Exact visible, frozen, or prefetched column runs required by the Grid.API reference →DataSourcePage.rows: RowData[]interface DataSourcePage {
rows: RowData[];
}interface DataSourcePage {
rows: RowData[];
}end-exclusive row rangeAPI reference →Array<RowData>.slice(start?: number, end?: number): RowData[]Array<RowData>.slice(start?: number, end?: number): RowData[]Array<RowData>.slice(start?: number, end?: number): RowData[]Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array.@param start The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0.@param end The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array.API reference →DataSourceRequest.end: numberinterface DataSourceRequest {
end: number;
}interface DataSourceRequest {
end: number;
}Exclusive row index.API reference →Array<RowData>.map<{
[k: string]: string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null;
}>(callbackfn: (value: RowData, index: number, array: RowData[]) => {
[k: string]: string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null;
}, thisArg?: any): {
[k: string]: string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null;
}[]Array<RowData>.map<{
[k: string]: string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null;
}>(callbackfn: (value: RowData, index: number, array: RowData[]) => {
[k: string]: string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null;
}, thisArg?: any): {
[k: string]: string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null;
}[]Array<RowData>.map<{
[k: string]: string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null;
}>(callbackfn: (value: RowData, index: number, array: RowData[]) => {
[k: string]: string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null;
}, thisArg?: any): {
[k: string]: string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null;
}[]Calls a defined callback function on each element of an array, and returns an array that contains the results.@param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.row: RowDatalet row: RowDatalet row: RowDataAPI reference →var Object: ObjectConstructorvar Object: ObjectConstructorvar Object: ObjectConstructorProvides functionality common to all JavaScript objects.ObjectConstructor.fromEntries<string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null>(entries: Iterable<readonly [PropertyKey, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null]>): {
...;
} (+1 overload)ObjectConstructor.fromEntries<string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null>(entries: Iterable<readonly [PropertyKey, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null]>): {
...;
} (+1 overload)ObjectConstructor.fromEntries<string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null>(entries: Iterable<readonly [PropertyKey, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null]>): {
...;
} (+1 overload)Returns an object created by key-value entries for properties and methods@param entries An iterable object that contains key-value entries for properties and methods.ReadonlyArray<DataSourceColumnBand>.flatMap<[string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null], undefined>(callback: (this: undefined, value: DataSourceColumnBand, index: number, array: DataSourceColumnBand[]) => [string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null] | readonly [...][], thisArg?: undefined): [...][]ReadonlyArray<DataSourceColumnBand>.flatMap<[string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null], undefined>(callback: (this: undefined, value: DataSourceColumnBand, index: number, array: DataSourceColumnBand[]) => [string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null] | readonly [...][], thisArg?: undefined): [...][]ReadonlyArray<DataSourceColumnBand>.flatMap<[string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null], undefined>(callback: (this: undefined, value: DataSourceColumnBand, index: number, array: DataSourceColumnBand[]) => [string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null] | readonly [...][], thisArg?: undefined): [...][]Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1.@param callback A function that accepts up to three arguments. The flatMap method calls the callback function one time for each element in the array.@param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used as the this value.band: DataSourceColumnBandlet band: DataSourceColumnBandlet band: DataSourceColumnBandAPI reference →DataSourceColumnBand.keys: readonly string[]interface DataSourceColumnBand {
keys: readonly string[];
}interface DataSourceColumnBand {
keys: readonly string[];
}Stable workbook column keys for every index in [start, end).API reference →ReadonlyArray<string>.map<[string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null]>(callbackfn: (value: string, index: number, array: readonly string[]) => [string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null], thisArg?: any): [...][]ReadonlyArray<string>.map<[string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null]>(callbackfn: (value: string, index: number, array: readonly string[]) => [string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null], thisArg?: any): [...][]ReadonlyArray<string>.map<[string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null]>(callbackfn: (value: string, index: number, array: readonly string[]) => [string, string | number | boolean | {
kind: "literal";
value: CellScalar;
} | {
kind: "ref";
target: CellAddress;
} | {
kind: "formula";
src: string;
} | {
value: CellValue;
style?: CellStyle;
} | null], thisArg?: any): [...][]Calls a defined callback function on each element of an array, and returns an array that contains the results.@param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.key: stringlet key: stringlet key: stringNon-empty key, unique within the sheet, used to map input and datasource values.API reference →interface DataSourceCapabilities {
protocol: 2;
columns: "windowed" | "full-width";
}interface DataSourceCapabilities {
protocol: 2;
columns: "windowed" | "full-width";
}interface DataSourceCapabilities {
protocol: 2;
columns:
"windowed" | "full-width";
}Declares whether a source can load only the requested column runs.API reference →interface DataSourceRequest {
protocol: 2;
sheet: SheetId;
start: number;
end: number;
columns: readonly DataSourceColumnBand[];
signal: AbortSignal;
revision: number;
}interface DataSourceRequest {
protocol: 2;
sheet: SheetId;
start: number;
end: number;
columns: readonly DataSourceColumnBand[];
signal: AbortSignal;
revision: number;
}interface DataSourceRequest {
protocol: 2;
sheet: SheetId;
start: number;
end: number;
columns: readonly DataSourceColumnBand[];
signal: AbortSignal;
revision: number;
}Cancellable sheet rectangle requested from a DataSource.API reference →interface DataSourcePage {
protocol: 2;
start: number;
columns: readonly DataSourceColumnBand[];
rows: RowData[];
revision?: string | number;
}interface DataSourcePage {
protocol: 2;
start: number;
columns: readonly DataSourceColumnBand[];
rows: RowData[];
revision?: string | number;
}interface DataSourcePage {
protocol: 2;
start: number;
columns: readonly DataSourceColumnBand[];
rows: RowData[];
revision?: string | number;
}One resolved rectangular page returned by a DataSource.API reference →