@trebco/treb 25.9.1 → 26.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-config.json +0 -1
- package/dist/treb-spreadsheet.mjs +13 -13
- package/dist/treb.d.ts +620 -3
- package/package.json +1 -1
- package/treb-base-types/src/cell.ts +11 -11
- package/treb-base-types/src/cells.ts +73 -7
- package/treb-base-types/src/import.ts +3 -3
- package/treb-base-types/src/value-type.ts +37 -5
- package/treb-embed/src/types.ts +41 -3
- package/treb-export/src/export2.ts +188 -5
- package/treb-export/src/import2.ts +21 -14
- package/treb-grid/src/types/data_model.ts +0 -1
- package/treb-grid/src/types/grid.ts +3 -1
- package/treb-grid/src/types/sheet_types.ts +45 -9
|
@@ -29,7 +29,7 @@ import { Parser } from 'treb-parser';
|
|
|
29
29
|
import type { RangeType, AddressType, HyperlinkType } from './address-type';
|
|
30
30
|
import { is_range, ShiftRange, InRange, is_address } from './address-type';
|
|
31
31
|
import type { ImportedSheetData, AnchoredAnnotation, CellParseResult, AnnotationLayout, Corner as LayoutCorner, ICellAddress, DataValidation, IArea } from 'treb-base-types/src';
|
|
32
|
-
import { ValueType, ValidationType } from 'treb-base-types/src';
|
|
32
|
+
import { type ValueType, ValidationType, type SerializedValueType } from 'treb-base-types/src';
|
|
33
33
|
import type { Sheet} from './workbook-sheet2';
|
|
34
34
|
import { VisibleState } from './workbook-sheet2';
|
|
35
35
|
import type { CellAnchor } from './drawing2/drawing2';
|
|
@@ -119,11 +119,13 @@ export class Importer {
|
|
|
119
119
|
// console.info(element);
|
|
120
120
|
|
|
121
121
|
let value: undefined | number | boolean | string;
|
|
122
|
-
let type: ValueType = ValueType.undefined;
|
|
122
|
+
// let type: ValueType = ValueType.undefined;
|
|
123
|
+
let type: SerializedValueType = 'undefined';
|
|
123
124
|
|
|
124
125
|
let calculated_value: undefined | number | boolean | string;
|
|
125
|
-
let calculated_type: ValueType = ValueType.undefined;
|
|
126
|
-
|
|
126
|
+
// let calculated_type: ValueType = ValueType.undefined;
|
|
127
|
+
let calculated_type: SerializedValueType = 'undefined';
|
|
128
|
+
|
|
127
129
|
// QUESTIONS:
|
|
128
130
|
//
|
|
129
131
|
// 1. is v always a value, or can it be an object?
|
|
@@ -147,7 +149,7 @@ export class Importer {
|
|
|
147
149
|
// console.info(address, 'e', element, 'm', mapped);
|
|
148
150
|
|
|
149
151
|
if (element.a$?.t && element.a$.t === 's') {
|
|
150
|
-
type = ValueType.string;
|
|
152
|
+
type = 'string'; // ValueType.string;
|
|
151
153
|
if (typeof element.v !== undefined) {
|
|
152
154
|
const index = Number(element.v);
|
|
153
155
|
if (!isNaN(index) && sheet.shared_strings) {
|
|
@@ -158,7 +160,7 @@ export class Importer {
|
|
|
158
160
|
}
|
|
159
161
|
else {
|
|
160
162
|
if (typeof element.f !== 'undefined') {
|
|
161
|
-
type = ValueType.formula;
|
|
163
|
+
type = 'formula'; // ValueType.formula;
|
|
162
164
|
|
|
163
165
|
const formula = (typeof element.f === 'string' ? element.f : element.f.t$) || '';
|
|
164
166
|
|
|
@@ -219,11 +221,11 @@ export class Importer {
|
|
|
219
221
|
if (typeof element.v !== 'undefined') {
|
|
220
222
|
const num = Number(element.v.toString());
|
|
221
223
|
if (!isNaN(num)) {
|
|
222
|
-
calculated_type = ValueType.number;
|
|
224
|
+
calculated_type = 'number'; // ValueType.number;
|
|
223
225
|
calculated_value = num;
|
|
224
226
|
}
|
|
225
227
|
else {
|
|
226
|
-
calculated_type = ValueType.string;
|
|
228
|
+
calculated_type = 'string'; // ValueType.string;
|
|
227
229
|
calculated_value = element.v.toString();
|
|
228
230
|
}
|
|
229
231
|
}
|
|
@@ -232,11 +234,11 @@ export class Importer {
|
|
|
232
234
|
else if (typeof element.v !== 'undefined') {
|
|
233
235
|
const num = Number(element.v.toString());
|
|
234
236
|
if (!isNaN(num)) {
|
|
235
|
-
type = ValueType.number;
|
|
237
|
+
type = 'number'; // ValueType.number;
|
|
236
238
|
value = num;
|
|
237
239
|
}
|
|
238
240
|
else {
|
|
239
|
-
type = ValueType.string;
|
|
241
|
+
type = 'string'; // ValueType.string;
|
|
240
242
|
value = element.v.toString();
|
|
241
243
|
}
|
|
242
244
|
}
|
|
@@ -254,7 +256,7 @@ export class Importer {
|
|
|
254
256
|
calculated_type = type;
|
|
255
257
|
calculated_value = value;
|
|
256
258
|
value = undefined;
|
|
257
|
-
type = ValueType.undefined;
|
|
259
|
+
type = 'undefined'; // ValueType.undefined;
|
|
258
260
|
}
|
|
259
261
|
}
|
|
260
262
|
|
|
@@ -833,11 +835,16 @@ export class Importer {
|
|
|
833
835
|
|
|
834
836
|
if (is_address(translated)) {
|
|
835
837
|
|
|
836
|
-
const result
|
|
838
|
+
const result: {
|
|
839
|
+
row: number;
|
|
840
|
+
column: number;
|
|
841
|
+
value: string;
|
|
842
|
+
type: SerializedValueType;
|
|
843
|
+
} = {
|
|
837
844
|
row: translated.row - 1,
|
|
838
845
|
column: translated.col - 1,
|
|
839
846
|
value: constructed_function,
|
|
840
|
-
type: ValueType.formula,
|
|
847
|
+
type: 'formula', // ValueType.formula,
|
|
841
848
|
};
|
|
842
849
|
|
|
843
850
|
let matched = false;
|
|
@@ -845,7 +852,7 @@ export class Importer {
|
|
|
845
852
|
for (const element of data) {
|
|
846
853
|
if (element.row === result.row && element.column === result.column) {
|
|
847
854
|
matched = true;
|
|
848
|
-
element.type = ValueType.formula;
|
|
855
|
+
element.type = 'formula'; // ValueType.formula;
|
|
849
856
|
element.value = constructed_function;
|
|
850
857
|
break;
|
|
851
858
|
}
|
|
@@ -805,7 +805,9 @@ export class Grid extends GridBase {
|
|
|
805
805
|
* be wiped from the model.
|
|
806
806
|
*/
|
|
807
807
|
public RemoveAnnotationNodes(): void {
|
|
808
|
-
this.
|
|
808
|
+
if (!this.headless) {
|
|
809
|
+
this.layout.RemoveAnnotationNodes();
|
|
810
|
+
}
|
|
809
811
|
}
|
|
810
812
|
|
|
811
813
|
/**
|
|
@@ -44,47 +44,83 @@ export interface ScrollOffset {
|
|
|
44
44
|
|
|
45
45
|
export interface SerializedSheet {
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
// data: any; // FIXME
|
|
47
|
+
/** cell data */
|
|
49
48
|
data: SerializedCellData;
|
|
50
49
|
|
|
50
|
+
/** top-level sheet style, if any */
|
|
51
51
|
sheet_style: Style.Properties;
|
|
52
|
+
|
|
53
|
+
/** row count */
|
|
52
54
|
rows: number;
|
|
55
|
+
|
|
56
|
+
/** column count */
|
|
53
57
|
columns: number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* cell styles is for empty cells that have styling
|
|
61
|
+
*/
|
|
54
62
|
cell_styles: Array<{row: number; column: number; ref: number, rows?: number}>;
|
|
55
63
|
|
|
56
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated use `styles` instead
|
|
66
|
+
*/
|
|
57
67
|
cell_style_refs?: Style.Properties[]; // old
|
|
58
|
-
styles?: Style.Properties[]; // new
|
|
59
68
|
|
|
69
|
+
/**
|
|
70
|
+
* new implementation
|
|
71
|
+
*/
|
|
72
|
+
styles?: Style.Properties[];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* per-row styles
|
|
76
|
+
*/
|
|
60
77
|
row_style: Record<number, Style.Properties|number>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* per-column styles
|
|
81
|
+
*/
|
|
61
82
|
column_style: Record<number, Style.Properties|number>;
|
|
62
83
|
|
|
63
84
|
/**
|
|
64
|
-
* @deprecated
|
|
85
|
+
* @deprecated no one uses this anymore and it's weird
|
|
65
86
|
*/
|
|
66
87
|
row_pattern?: Style.Properties[];
|
|
67
88
|
|
|
89
|
+
/** default for new rows */
|
|
68
90
|
default_row_height?: number;
|
|
91
|
+
|
|
92
|
+
/** default for new columns */
|
|
69
93
|
default_column_width?: number;
|
|
70
94
|
|
|
95
|
+
/** list of row heights. we use a Record instead of an array because it's sparse */
|
|
71
96
|
row_height?: Record<number, number>;
|
|
97
|
+
|
|
98
|
+
/** list of column widths. we use a Record instead of an array because it's sparse */
|
|
72
99
|
column_width?: Record<number, number>;
|
|
73
|
-
named_ranges?: Record<string, IArea>;
|
|
74
100
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated these were moved to the containing document
|
|
103
|
+
*/
|
|
104
|
+
named_ranges?: Record<string, IArea>;
|
|
78
105
|
|
|
79
106
|
freeze?: FreezePane;
|
|
80
107
|
|
|
108
|
+
/** sheet ID, for serializing references */
|
|
81
109
|
id?: number;
|
|
110
|
+
|
|
111
|
+
/** sheet name */
|
|
82
112
|
name?: string;
|
|
83
113
|
|
|
114
|
+
/** current active selection */
|
|
84
115
|
selection: GridSelection;
|
|
116
|
+
|
|
117
|
+
/** */
|
|
85
118
|
annotations?: Partial<AnnotationData>[]; // Partial<Annotation>[];
|
|
119
|
+
|
|
120
|
+
/** current scroll position */
|
|
86
121
|
scroll?: ScrollOffset;
|
|
87
122
|
|
|
123
|
+
/** visible flag. we only support visible/hidden */
|
|
88
124
|
visible?: boolean;
|
|
89
125
|
|
|
90
126
|
/** testing */
|