@univerjs-pro/engine-pivot
Version:
Pivot table calculation engine for Univer Pro.
142 lines (141 loc) • 5.72 kB
TypeScript
import type { PivotModel } from '../pivot/model';
import type { ILabelViewHeaderMapItem, ILabelViewItemJSON, IPageViewItemJSON, IPageViewItemRange, IPivotTableGroupInfo, IPivotViewCellData, IPivotViewErrorValue, IPivotViewInfo, IPivotViewItemData, IPivotViewItemJSON, IPivotViewJSON, IPivotViewPrefixValue, IPivotViewValueType, PivotCellStyleTypeEnum } from '../types';
/**
* @class PivotView
* @description the view of pivot table, which contains the page, row, col, data view, the page view separation the pivot table to two areas, the row and col view as the header of data area
*/
export declare class PivotView {
/**
* the page view of the pivot table
*/
pageView: PageViewItem;
/**
* the row view of the pivot table
*/
rowView: LabelViewItem;
/**
* the col view of the pivot table
*/
colView: LabelViewItem;
/**
* the data view of the pivot table
*/
dataView: PivotViewItem;
/**
* the corner view of the pivot table
*/
cornerView: PivotViewItem;
/**
* the version of the pivot view, it will be used to check the view is the latest
*/
version: number;
/**
* the format map of the table field id, it will be used to store the format of the pivot view
*/
formatMap: Record<string, string>;
/**
* the group info map of the table field id, it will be used to store the group info of the pivot view
*/
groupInfo: Record<string, IPivotTableGroupInfo>;
constructor();
setVersion(version?: number): void;
setGroupInfo(groupInfo: Record<string, IPivotTableGroupInfo>): void;
/**
* - the func effect is to set the format code , for label view, it will used to format the header , such as date type data, in the data view, it will used to format the data of show data as
* @param model the pivot model, it will be used to set the format of the pivot view
*/
setFormat(model: PivotModel): void;
getVersion(): number;
toJSON(): IPivotViewJSON;
formJSON(data: IPivotViewJSON): void;
}
export declare class PivotViewItem {
/**
* - how many rows in the view
*/
rowCount: number;
/**
* - how many cols in the view
*/
colCount: number;
/**
* the data of the view, the key is the row index, the value is the column data
*/
data: IPivotViewItemData;
/**
* the info of the view, the index is the index of the view item, the value is the info of the view item
*/
info: IPivotViewInfo[];
lastCol: number;
lastRow: number;
getLastCol(): number;
getLastRow(): number;
setValue(row: number, col: number, value: IPivotViewValueType): void;
setStyle(row: number, col: number, styleType: PivotCellStyleTypeEnum): void;
setBlank(row: number, col: number): void;
setOther(row: number, col: number): void;
protected getCell(row: number, col: number): IPivotViewCellData;
setInfo(index: number, info: IPivotViewInfo): void;
buildPathMap(considerValue: boolean): Record<string, number>;
setRowCount(rowCount: number): void;
setColCount(colCount: number): void;
getRowCount(): number;
getColCount(): number;
getValue(row: number, col: number): IPivotViewValueType;
getStyle(row: number, col: number): PivotCellStyleTypeEnum | undefined;
toJSON(): IPivotViewItemJSON;
fromJSON(json: IPivotViewItemJSON): void;
}
export declare class PageViewItem extends PivotViewItem {
/**
* the range group of the page view, all range is base on the left top of the page view
*/
ranges: IPageViewItemRange[];
/**
* the last col index of the page view
*/
lastCol: number;
/**
* the last row index of the page view
*/
lastRow: number;
setPageIndex(row: number, col: number, index: number): void;
addRange(range: IPageViewItemRange): void;
getRanges(): IPageViewItemRange[];
setLastCol(col: number): void;
setLastRow(row: number): void;
getLastCol(): number;
getLastRow(): number;
toJSON(): IPageViewItemJSON;
fromJSON(json: IPageViewItemJSON): void;
}
export declare class LabelViewItem extends PivotViewItem {
/**
* this property is used to store the header map of the label view
* - in the row view, the header map saved the every column in row view, the key is the column index, the value is the header map item
* - in the col view, the header map saved the every row in col view, the key is the row index, the value is the header map item
*/
headerMap: ILabelViewHeaderMapItem[];
addHeaderMapItem(index: number, item: ILabelViewHeaderMapItem): void;
getHeaderMapItem(index: number): ILabelViewHeaderMapItem;
toJSON(): ILabelViewItemJSON;
fromJSON(json: ILabelViewItemJSON): void;
}
export declare class RowViewItem extends LabelViewItem {
getLastCol(): number;
}
export declare class ColViewItem extends LabelViewItem {
getLastRow(): number;
}
/**
* judge the value is the prefix value, once when the value is a subtotal and there are multiple value field, the value will be the prefix value
* @param {IPivotViewValueType} value the pivot view value
* @returns {boolean} the value is the prefix value
*/
export declare const isPrefixValue: (value: IPivotViewValueType) => value is IPivotViewPrefixValue;
/**
* judge the value is the error value, it will be a error value when the show data as or the product bigger than the max value of number in javascript
* @param {IPivotViewValueType} value - the pivot view value
* @returns {boolean} the value is the error value
*/
export declare const isErrorValue: (value: IPivotViewValueType) => value is IPivotViewErrorValue;