@sheetxl/models
Version:
Models - A Headless javascript spreadsheet library.
144 lines • 5.62 kB
TypeScript
import { Size, AnchorLocation, Rectangle } from "@sheetxl/common";
import { ITextFrame } from "../text";
import { ParsedNumberFormat } from "../utils/NumberFormatParser";
import { HorizontalAlignment } from "../text";
import { ICellStyle } from "./ICellStyle";
import { IHyperlink } from "./IHyperlink";
import { ICellValue, CellType, CellUpdate } from "./CellTypes";
export interface ICalcCellValues {
readonly rowSpan: number;
readonly colSpan: number;
}
/**
* Immutable representation of a cell within a sheet.
* Use @see {@link ISheetModel} to set/update/clear cells.
*/
export interface ICellModel {
/**
* The value of the cell.
*/
readonly value: ICellValue;
readonly type: CellType;
readonly style: ICellStyle;
/**
* If the cell is merged then the colSpan will be greater than 1
*/
readonly colSpan: number;
/**
* If the cell is merged then the rowSpan will be greater than 1
*/
readonly rowSpan: number;
/**
* Returns that values as an unformatted string. This is useful for copy/export.
* Note - Even in the case of unformatted text we do a 'minimum' amount. For example we convert dates, percentages, and times.
*/
readonly asTextUnformatted: string | null;
/**
* Will try to return the value as a displayable string
* @remarks
* This will have the numberFormatting applied.
* @see {@link asTextUnformatted}
*/
readonly asText: string | null;
/**
* Will try to return the value as a javascript date.
*/
readonly asDate: Date | null;
/**
* Returns the value as formatted text using @see {@link NumberFormatParser}.
* This is the textValue as a string with additional rendering info from the NumberFormat
* formattedValue.displayText.
*/
readonly formattedValue: ParsedNumberFormat | null;
/**
* Allows for parsing a number format for the current cell with with a different numberFormat.
* @param numberFormat
*/
parseNumberFormat(numberFormat: string): ParsedNumberFormat;
/**
* Used for creating padding around content.
* Note - insets do not effect fills or backgrounds
*/
insets(): Rectangle;
/**
* Contains an ITextFrame.
* This can be null if this cell does not contain text.
* This is the final textFrame that includes the formattedValue as well as additional text layout information
* such as wrapping, alignment, etc. In addition rich text will be here
*/
readonly textFrame: ITextFrame;
/**Hyperlink if set or null */
readonly hyperlink: IHyperlink;
/**
* A list of comments.
* TODO - not implemented yet. This will be a proper comment type.
*/
readonly comments: string[] | null;
/**
* Used to calculate the size that will best display the cell
* When calculating bestFit for rows or columns this will be used.
*
* If null is returned then this cell will be ignore for sizing purposes.
* Additionally either dimension can be null unspecified. Indicating that
* this direction will not be used.
* @param colWidth - The width of the column. Text uses this to wrap
* @param fullContent - @defaultValue falseIf true then the cell will try to size with the minimum amount of space.
*/
bestFitSize(colWidth: number, fullContent?: boolean): Partial<Size> | null;
/**
* If a cell can overflow.
* @remarks Currently only cells can overflow to the left or right.
*/
readonly couldOverflow: boolean;
/**
* Used to calculate overflow. This is the entire size of the cell if there is overflow.
* If there is no overflow then this is null.
* This is slightly different than best fit in that it only measures offsetting insets
* @remarks This can be an expensive operations as it requires measuring the cell.
*/
readonly overflowSize: Size | null;
/**
* This is used with overflowSize to calculate overflow.
* @see {@link overflowSize}
* Only AnchorLocation.LEFT, AnchorLocation.CENTER, AnchorLocation.RIGHT are currently supported
*/
readonly overflowAnchor: AnchorLocation;
/**
* Returns the alignment to use when rendering the text.
* This is not just the style alignment because the type of cell can also influence
*
*/
readonly renderHorizontalAlignment: HorizontalAlignment;
/**
* If the cell is contained within a spill area. This include the range of spilled content. The top/left will include the reference to the formula with the spill
*/
/**
* If a cell has a value. Note - If may or may not have styling or other characteristics. (for example row/col spans borders, etc)
*/
isContentful(): boolean;
/**
* If there is no value and a normal style
*/
isEmpty(): boolean;
/**
* If the cell is readonly. This can can because the sheet is protected or locked or other.
*/
isReadOnly(): boolean;
/**
* If the two cells are logically equal..
* @param other
*/
isEqual(other: ICellModel): boolean;
/**
* convenience for calling the constructor.
*/
cloneWithUpdate(update: CellUpdate, calcedValues?: ICalcCellValues): ICellModel | null;
readonly calcedValues: ICalcCellValues;
/**
* If the cell has warnings. Not this is different than an error as this will replace the value and type
*/
readonly warnings: string[] | null;
readonly formula: string | null;
readonly isCellModel: true;
}
//# sourceMappingURL=ICellModel.d.ts.map