name:
dist/Cell.d.ts
-rw-r--r--
4030
1declare const CELL_ID_ERROR = "CELL_ID_ERROR";
2/**
3 * Represents a cell id error, and is thrown when a cells id does not conform to A1 notation.
4 */
5declare class CellIdError extends Error {
6 constructor(msg: string);
7}
8/**
9 * Cell represents a cell in the spreadsheet. It contains a nullable rawFormulaText, and a value, which is not nullable unless
10 * the parsing of the rawFormulaText results in an error.
11 */
12declare class Cell {
13 /**
14 * The raw formula text that can be parse, excluding the proceeding =
15 * E.g: SUM(A2:A4, 10)
16 */
17 private rawFormulaText;
18 private typedValue;
19 private dependencies;
20 private error;
21 private id;
22 private row;
23 private col;
24 /**
25 * Creates an empty cell with an id.
26 * @param id key of the cell in A1-format.
27 */
28 constructor(id: string);
29 /**
30 * Update this cell's dependencies, where `dependencies` is a unique list of A1-format cell IDs.
31 * @param dependencies to merge with existing dependencies.
32 */
33 updateDependencies(dependencies: Array<string>): void;
34 /**
35 * Return a list of dependencies in A1-format cell IDs, in no particular order, but likely in order of occurrence in
36 * rawFormulaText.
37 * @returns {Array<string>} list of dependencies in A1-format
38 */
39 getDependencies(): Array<string>;
40 /**
41 * Return the zero-indexed column number of this cell.
42 * @returns {number} column
43 */
44 getColumn(): number;
45 /**
46 * Return the zero-indexed row number of this cell.
47 * @returns {number} row
48 */
49 getRow(): number;
50 /**
51 * Get the A1-format ID of this cell.
52 * @returns {string} cell ID
53 */
54 getId(): string;
55 /**
56 * Get the rawFormulaText of this cell if set. Defaults to null, so should be used in combination with hasFormula().
57 * @returns {string} rawFormulaText of this cell, if set. Nullable.
58 */
59 getFormula(): string;
60 /**
61 * Returns true if this cell has a formula to be parsed.
62 * @returns {boolean}
63 */
64 hasFormula(): boolean;
65 /**
66 * Sets the value or rawFormulaText for this cell. If the input begins with =, then it is considered to be a rawFormulaText. If it
67 * is not, then it is a value, and set as the raw value for this cell.
68 * @param rawFormula
69 */
70 setValue(rawFormula: string): void;
71 /**
72 * Gets the rawFormulaText for this cell, which is either null or a string.
73 * @returns {string}
74 */
75 getRawFormulaText(): string | null;
76 /**
77 * Get the value of this cell if a value is present. If this cell was given a formula but not a value, this may return
78 * null.
79 * @returns {any}
80 */
81 getValue(): any;
82 /**
83 * CLears a cells value.
84 */
85 clearValue(): void;
86 /**
87 * Set error for this cell. Usually in the case of a parse error when parsing the rawFormulaText.
88 * @param error to set.
89 */
90 setError(error: Error): void;
91 /**
92 * Get the error for this cell. If the rawFormulaText is not parsed properly, or is null, this could be null.
93 * @returns {Error} error to return, could be null.
94 */
95 getError(): Error;
96 /**
97 * Easier way to check if this cell has an error.
98 * @returns {boolean}
99 */
100 hasError(): boolean;
101 /**
102 * A cell is deemed blank if it contains no value, no error, and no typed value.
103 * @returns {boolean}
104 */
105 isBlank(): boolean;
106 /**
107 * Returns the human-readable string representation of this cell, omitting some obvious fields.
108 * @returns {string}
109 */
110 toString(): string;
111 /**
112 * Comparing two cells.
113 * @param other
114 * @returns {boolean}
115 */
116 equals(other: Cell): boolean;
117 /**
118 * Build a cell with an id and value.
119 * @param id - A1-notation id or key.
120 * @param value - value of the cell as a string
121 * @returns {Cell}
122 * @constructor
123 */
124 static BuildFrom(id: string, value: any): Cell;
125}
126export { Cell, CellIdError, CELL_ID_ERROR };