@jsfkit/types 1.0.0
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/LICENCE +21 -0
- package/README.md +3 -0
- package/dist/index.d.ts +581 -0
- package/dist/index.js +0 -0
- package/package.json +47 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT Licence
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Borgar Þorsteinsson and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A whole number without a fractional value.
|
|
3
|
+
*/
|
|
4
|
+
type integer = number;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Directions on how formulas should be recalculated in the workbook.
|
|
8
|
+
*/
|
|
9
|
+
type CalcProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Specifies whether an attempt should be made to calculate formulas that contain circular
|
|
12
|
+
* references. Defaults to `false` in Excel.
|
|
13
|
+
*/
|
|
14
|
+
iterate: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The maximum number of calculation iterations, when `iterate` is `true`. Defaults to `100` in
|
|
17
|
+
* Excel.
|
|
18
|
+
*/
|
|
19
|
+
iterateCount: integer;
|
|
20
|
+
/**
|
|
21
|
+
* When a calculation iteration results in an absolute change that is less than iterateDelta,
|
|
22
|
+
* then no further iterations should be attempted. Defaults to `0.001` in Excel.
|
|
23
|
+
*/
|
|
24
|
+
iterateDelta: number;
|
|
25
|
+
/**
|
|
26
|
+
* Which of the two date systems the workbook uses. 1900 is the default.
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://support.microsoft.com/office/e7fe7167-48a9-4b96-bb53-5612a800b487}
|
|
29
|
+
*/
|
|
30
|
+
epoch?: 1900 | 1904;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Defines the type of a value contained within a cell.
|
|
35
|
+
*/
|
|
36
|
+
type CellValueType = 'b' | 'e' | 'n' | 'd' | 's' | 'z';
|
|
37
|
+
|
|
38
|
+
/** A cell comment. */
|
|
39
|
+
type Comment = {
|
|
40
|
+
/** Author of the comment. */
|
|
41
|
+
a: string;
|
|
42
|
+
/** Date of the comment (as an ISO formatted string). */
|
|
43
|
+
d: string;
|
|
44
|
+
/** The text content of the comment. */
|
|
45
|
+
t: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A spreadsheet cell.
|
|
50
|
+
*/
|
|
51
|
+
type Cell = {
|
|
52
|
+
/**
|
|
53
|
+
* The value of the cell. The result of a calculation if the cell has a formula, otherwise safe to
|
|
54
|
+
* assume that it's user-entered.
|
|
55
|
+
*
|
|
56
|
+
* @default null
|
|
57
|
+
*/
|
|
58
|
+
v?: string | null | number | boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Cell formula expression. When the value is a string it will be a formula with A1-style
|
|
61
|
+
* references. When the value is a number is an index to a formula in the workbook's `formulas`
|
|
62
|
+
* array.
|
|
63
|
+
*/
|
|
64
|
+
f?: string | integer;
|
|
65
|
+
/** The range of enclosing array if the formula is an array formula. */
|
|
66
|
+
F?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Cell hyperlink. Must be a URL.
|
|
69
|
+
*/
|
|
70
|
+
l?: string;
|
|
71
|
+
/**
|
|
72
|
+
* An index to a style in the workbook's `styles`.
|
|
73
|
+
*
|
|
74
|
+
* @default 0
|
|
75
|
+
*/
|
|
76
|
+
s?: integer;
|
|
77
|
+
/**
|
|
78
|
+
* Comments associated with the cell.
|
|
79
|
+
*/
|
|
80
|
+
c?: Comment[];
|
|
81
|
+
/**
|
|
82
|
+
* The type of the value contained in the cell. Cells with errors or dates must include this
|
|
83
|
+
* property, but it's otherwise optional (the type can be inferred from the `v` property).
|
|
84
|
+
*/
|
|
85
|
+
t?: CellValueType;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A cell coordinate in an uppercase A1-style reference format (e.g. `AG14`).
|
|
90
|
+
*
|
|
91
|
+
* The lower top-left bounds of the reference are A1-inclusive, and the upper bottom-right bound are
|
|
92
|
+
* `XFD1048576` inclusive.
|
|
93
|
+
*
|
|
94
|
+
* @pattern ^[A-Z]{1,3}[0-9]{1,3}$
|
|
95
|
+
*/
|
|
96
|
+
type CellId = string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A cell coordinate range in an uppercase A1-style reference format (e.g. `H6:J36`).
|
|
100
|
+
*
|
|
101
|
+
* The range consists of two {@link CellId}s separated by a colon (`:`) character.
|
|
102
|
+
*
|
|
103
|
+
* @pattern ^([A-Z]{1,3}[0-9]{1,3}):([A-Z]{1,3}[0-9]{1,3})$
|
|
104
|
+
*/
|
|
105
|
+
type CellRange = string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A defined name (also called "named range") is a labelled reference to a cell, range, constant or
|
|
109
|
+
* formula. Meaningful labels can make formula expressions more readable and more robust to
|
|
110
|
+
* worksheet edits.
|
|
111
|
+
*
|
|
112
|
+
* ```json
|
|
113
|
+
* { "name": "Rates",
|
|
114
|
+
* "scope": "Sheet1",
|
|
115
|
+
* "value": "Sheet1!B1:C1" }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
type DefinedName = {
|
|
119
|
+
/**
|
|
120
|
+
* A case-sensitive name. Names must start with a letter or `_`, and may only be made up of
|
|
121
|
+
* letters as well as `\`, `_`, `.`, or `?`. Names must be a valid A1 or R1C1 reference.
|
|
122
|
+
*/
|
|
123
|
+
name: string;
|
|
124
|
+
/**
|
|
125
|
+
* A formula expression, a reference, or value. Whatever the value is will be evaluated by a
|
|
126
|
+
* spreadsheet engine as if it were an expression.
|
|
127
|
+
*/
|
|
128
|
+
value?: string;
|
|
129
|
+
/**
|
|
130
|
+
* An optional worksheet name that defines the scope for this name. When this field is absent,
|
|
131
|
+
* the defined name should be considered to be scoped to the workbook.
|
|
132
|
+
*/
|
|
133
|
+
scope?: string;
|
|
134
|
+
/**
|
|
135
|
+
* An optional comment explaining the defined name.
|
|
136
|
+
*/
|
|
137
|
+
comment?: string;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* A simple container sheet for cell values within an external workbook.
|
|
142
|
+
*/
|
|
143
|
+
type ExternalWorksheet = {
|
|
144
|
+
/**
|
|
145
|
+
* Name of the worksheet.
|
|
146
|
+
*/
|
|
147
|
+
name: string;
|
|
148
|
+
/**
|
|
149
|
+
* The cells belonging to the worksheet that have any data attached.
|
|
150
|
+
*
|
|
151
|
+
* Typically, these will have only values and calculation directives attached as they will not
|
|
152
|
+
* be rendered by a spreadsheet application.
|
|
153
|
+
*/
|
|
154
|
+
cells: Record<CellId, Cell>;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* A cell from another workbook (i.e. another file) that is referenced in this workbook.
|
|
159
|
+
*/
|
|
160
|
+
type External = {
|
|
161
|
+
/** Filename being referenced. */
|
|
162
|
+
name: string;
|
|
163
|
+
/**
|
|
164
|
+
* Relevant worksheets from an external workbook.
|
|
165
|
+
*
|
|
166
|
+
* These will only be a subset of sheets needed to run calculations, so indexes from the original
|
|
167
|
+
* workbooks will not be preserved.
|
|
168
|
+
*/
|
|
169
|
+
sheets: ExternalWorksheet[];
|
|
170
|
+
/** Relevant defined names from an external workbook. */
|
|
171
|
+
names: DefinedName[];
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* A numeric value measured in pixels.
|
|
176
|
+
*
|
|
177
|
+
* @min 0
|
|
178
|
+
*/
|
|
179
|
+
type PixelValue = number;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A size of a UI-grid measure over a range of items.
|
|
183
|
+
*
|
|
184
|
+
* GridSize information is run-length encoded. The start and end attributes indicate the range of
|
|
185
|
+
* items that the `size` and `s` attributes affect. The range is expressed using integers, where
|
|
186
|
+
* 1 corresponds to column A or row 1.
|
|
187
|
+
*
|
|
188
|
+
* GridSize may have a style-index (`s`) attribute like individual cells. The styling information on
|
|
189
|
+
* the column should be used for all cells that are not present in the sheet's cell collection.
|
|
190
|
+
*/
|
|
191
|
+
type GridSize = {
|
|
192
|
+
/** A 1-based inclusive start index. */
|
|
193
|
+
start: integer;
|
|
194
|
+
/** A 1-based inclusive end index. */
|
|
195
|
+
end: integer;
|
|
196
|
+
/** The size of the grid item in pixels. */
|
|
197
|
+
size: PixelValue;
|
|
198
|
+
/** An index to a style in the workbook styles. */
|
|
199
|
+
s?: integer;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The style to use when drawing a cell border. If the worksheet's zoom factor is changed the width
|
|
204
|
+
* of the border is expected to stay the same.
|
|
205
|
+
*
|
|
206
|
+
* - `none`: no border is drawn.
|
|
207
|
+
* - `dashDot`: equivalent to SVG `stroke-dasharray="4 1 2 1"`, at a 1px width.
|
|
208
|
+
* - `dashDotDot`: equivalent to SVG `stroke-dasharray="4 1 2 1 2 1"`, at a 1px width.
|
|
209
|
+
* - `dashed`: equivalent to SVG `stroke-dasharray=""3 1`, at a 1px width.
|
|
210
|
+
* - `dotted`: equivalent to SVG `stroke-dasharray="1"`, at a 1px width.
|
|
211
|
+
* - `double`: draw two 1px wide continuous parallel lines with a 1px gap between them.
|
|
212
|
+
* - `hair`: draw a 1px wide pixel continuous hairline.
|
|
213
|
+
* - `medium`: draw a 2px wide pixel continuous line.
|
|
214
|
+
* - `mediumDashDot`: equivalent to SVG `stroke-dasharray="4 1 2 1"`, at a 2px width.
|
|
215
|
+
* - `mediumDashDotDot`: equivalent to SVG `stroke-dasharray="4 1 2 1 2 1"`, at a 2px width.
|
|
216
|
+
* - `mediumDashed`: equivalent to SVG `stroke-dasharray=""3 1`, at a 2px width.
|
|
217
|
+
* - `slantDashDot`: draw two 1px parallel dashed lines where the lower/left line 1px "behind" the
|
|
218
|
+
* other, creating a slant.
|
|
219
|
+
* - `thick`: draw a 3px wide pixel continuous line.
|
|
220
|
+
* - `thin`: draw a 1px wide pixel continuous line.
|
|
221
|
+
*/
|
|
222
|
+
type BorderStyle = 'none' | 'dashDot' | 'dashDotDot' | 'dashed' | 'dotted' | 'double' | 'hair' | 'medium' | 'mediumDashDot' | 'mediumDashDotDot' | 'mediumDashed' | 'slantDashDot' | 'thick' | 'thin';
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* A hex-encoded RGB or RGBA value that conforms to the CSS4 color specification (e.g. `"#3cb371"`).
|
|
226
|
+
*
|
|
227
|
+
* @see {@link https://www.w3.org/TR/css-color-4/#hex-notation|CSS spec}
|
|
228
|
+
* @pattern ^#([a-fA-F0-9]{3,4}|([a-fA-F0-9][a-fA-F0-9]){3,4})$
|
|
229
|
+
*/
|
|
230
|
+
type Color = `#${string}`;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Specifies the horizontal alignment of content (text) within a container (cell).
|
|
234
|
+
*
|
|
235
|
+
* - `center`: the horizontal alignment is centered, meaning the text is centered across the cell.
|
|
236
|
+
* - `centerContinuous`: the horizontal alignment is centered across multiple cells.
|
|
237
|
+
* - `distributed`: indicates that each 'word' in each line of text inside the cell is evenly
|
|
238
|
+
* distributed across the width of the cell, with flush right and left margins.
|
|
239
|
+
* - `fill`: indicates that the value of the cell should be filled across the entire width of the
|
|
240
|
+
* cell. If blank cells to the right also have the fill alignment, they are also filled with the
|
|
241
|
+
* value, using a convention similar to `centerContinuous`.
|
|
242
|
+
* - `general`: the horizontal alignment is general-aligned. Text data is left-aligned. Numbers,
|
|
243
|
+
* dates, and times are right- aligned. Boolean types are centered.
|
|
244
|
+
* - `justify`: for each line of text, aligns each line of the wrapped text in a cell to the right
|
|
245
|
+
* and left (except the last line).
|
|
246
|
+
* - `left`: aligns content at the left edge of the cell (even in RTL mode).
|
|
247
|
+
* - `right`: aligns content at the right edge of the cell (even in RTL mode).
|
|
248
|
+
*/
|
|
249
|
+
type HAlign = 'general' | 'left' | 'center' | 'right' | 'fill' | 'justify' | 'centerContinuous' | 'distributed';
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The style of fill pattern used for a cell background. If the worksheets zoom factor is changed
|
|
253
|
+
* the pixel scale of the pattern is still expected to stay the same.
|
|
254
|
+
*/
|
|
255
|
+
type PatternStyle = 'none' | 'solid' | 'mediumGray' | 'darkGray' | 'lightGray' | 'darkHorizontal' | 'darkVertical' | 'darkDown' | 'darkUp' | 'darkGrid' | 'darkTrellis' | 'lightHorizontal' | 'lightVertical' | 'lightDown' | 'lightUp' | 'lightGrid' | 'lightTrellis' | 'gray125' | 'gray0625';
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Which type of underline to use when rendering text.
|
|
259
|
+
*/
|
|
260
|
+
type Underline = 'none' | 'single' | 'singleAccounting' | 'double' | 'doubleAccounting';
|
|
261
|
+
|
|
262
|
+
/** Vertical alignment of a cell content. */
|
|
263
|
+
type VAlign = 'bottom' | 'top' | 'center' | 'justify' | 'distributed';
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Style rules that specify the visual presentation of a cell.
|
|
267
|
+
*/
|
|
268
|
+
type Style = {
|
|
269
|
+
/**
|
|
270
|
+
* The name of the font family used to render text, e.g. `"Arial"`.
|
|
271
|
+
*
|
|
272
|
+
* @default "Calibri"
|
|
273
|
+
*/
|
|
274
|
+
fontFamily?: string;
|
|
275
|
+
/**
|
|
276
|
+
* The font size in pixels.
|
|
277
|
+
*
|
|
278
|
+
* @default 11
|
|
279
|
+
*/
|
|
280
|
+
fontSize?: PixelValue;
|
|
281
|
+
/**
|
|
282
|
+
* The color used to render text.
|
|
283
|
+
*
|
|
284
|
+
* @default "#000"
|
|
285
|
+
*/
|
|
286
|
+
color?: Color;
|
|
287
|
+
/**
|
|
288
|
+
* Indicates whether the text is bold.
|
|
289
|
+
*
|
|
290
|
+
* @default false
|
|
291
|
+
*/
|
|
292
|
+
bold?: boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Indicates whether the text is italic.
|
|
295
|
+
*
|
|
296
|
+
* @default false
|
|
297
|
+
*/
|
|
298
|
+
italic?: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Text underline decoration type.
|
|
301
|
+
*
|
|
302
|
+
* @default "none"
|
|
303
|
+
*/
|
|
304
|
+
underline?: Underline;
|
|
305
|
+
/**
|
|
306
|
+
* The cell's background color.
|
|
307
|
+
*
|
|
308
|
+
* @default "#FFFFFF"
|
|
309
|
+
*/
|
|
310
|
+
fillColor?: Color;
|
|
311
|
+
/**
|
|
312
|
+
* The color of a cell's background fill.
|
|
313
|
+
*
|
|
314
|
+
* @default "#000000"
|
|
315
|
+
*/
|
|
316
|
+
patternColor?: Color;
|
|
317
|
+
/**
|
|
318
|
+
* The style of a cell's background fill.
|
|
319
|
+
*
|
|
320
|
+
* @default "none"
|
|
321
|
+
*/
|
|
322
|
+
patternStyle?: PatternStyle;
|
|
323
|
+
/**
|
|
324
|
+
* Top border style.
|
|
325
|
+
*
|
|
326
|
+
* @default "none"
|
|
327
|
+
*/
|
|
328
|
+
borderTopStyle?: BorderStyle;
|
|
329
|
+
/**
|
|
330
|
+
* Top border color.
|
|
331
|
+
*/
|
|
332
|
+
borderTopColor?: Color;
|
|
333
|
+
/**
|
|
334
|
+
* Left border style.
|
|
335
|
+
*
|
|
336
|
+
* @default "none"
|
|
337
|
+
*/
|
|
338
|
+
borderLeftStyle?: BorderStyle;
|
|
339
|
+
/**
|
|
340
|
+
* Left border color.
|
|
341
|
+
*/
|
|
342
|
+
borderLeftColor?: Color;
|
|
343
|
+
/**
|
|
344
|
+
* Bottom border style.
|
|
345
|
+
*
|
|
346
|
+
* @default "none"
|
|
347
|
+
*/
|
|
348
|
+
borderBottomStyle?: BorderStyle;
|
|
349
|
+
/**
|
|
350
|
+
* Bottom border color.
|
|
351
|
+
*/
|
|
352
|
+
borderBottomColor?: Color;
|
|
353
|
+
/**
|
|
354
|
+
* Right border style.
|
|
355
|
+
*
|
|
356
|
+
* @default "none"
|
|
357
|
+
*/
|
|
358
|
+
borderRightStyle?: BorderStyle;
|
|
359
|
+
/**
|
|
360
|
+
* Right border color.
|
|
361
|
+
*/
|
|
362
|
+
borderRightColor?: Color;
|
|
363
|
+
/**
|
|
364
|
+
* Horizontal alignment of the cells [text] content.
|
|
365
|
+
*
|
|
366
|
+
* @default "general"
|
|
367
|
+
*/
|
|
368
|
+
horizontalAlignment?: HAlign;
|
|
369
|
+
/**
|
|
370
|
+
* Vertical alignment of the cells [text] content.
|
|
371
|
+
*
|
|
372
|
+
* @default "bottom"
|
|
373
|
+
*/
|
|
374
|
+
verticalAlignment?: VAlign;
|
|
375
|
+
/**
|
|
376
|
+
* Indicates whether text should be wrapped when it exceeds the cell's width.
|
|
377
|
+
*
|
|
378
|
+
* @default false
|
|
379
|
+
*/
|
|
380
|
+
wrapText?: boolean;
|
|
381
|
+
/**
|
|
382
|
+
* Indicates whether the font-size should be automatically reduced in order to make the contents
|
|
383
|
+
* of the cell visible.
|
|
384
|
+
*/
|
|
385
|
+
shrinkToFit?: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* The degrees to which the cell text should be rotated. Values range from 0 to 180, and 255 to
|
|
388
|
+
* indicate vertical text. The origin of the rotation is the first letter of the text.
|
|
389
|
+
*/
|
|
390
|
+
textRotation?: boolean;
|
|
391
|
+
/**
|
|
392
|
+
* Formatting directions for rendering the cell's value to text.
|
|
393
|
+
*/
|
|
394
|
+
numberFormat?: string;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
/** Describes the type of values found in the cells of a table column. */
|
|
398
|
+
type TableColumnDataType = 'text' | 'number' | 'boolean' | 'datetime' | 'unknown';
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Describes a column within a table.
|
|
402
|
+
*/
|
|
403
|
+
type TableColumn = {
|
|
404
|
+
/**
|
|
405
|
+
* The column name. It must be unique among column names in the same table when compared in a
|
|
406
|
+
* case-insensitive manner. Must be non-empty. May contain white-space characters but not
|
|
407
|
+
* exclusively.
|
|
408
|
+
*/
|
|
409
|
+
name: string;
|
|
410
|
+
/**
|
|
411
|
+
* Describes the type of values found in the cells of the column, when a column contains only one
|
|
412
|
+
* data type.
|
|
413
|
+
*
|
|
414
|
+
* @default "unknown"
|
|
415
|
+
*/
|
|
416
|
+
dataType?: TableColumnDataType;
|
|
417
|
+
/**
|
|
418
|
+
* If the column is a calculated column, then this field must include the formula used.
|
|
419
|
+
*/
|
|
420
|
+
formula?: string;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
/** Excel's built-in table style names. */
|
|
424
|
+
type TableStyleName = 'TableStyleDark1' | 'TableStyleDark2' | 'TableStyleDark3' | 'TableStyleDark4' | 'TableStyleDark5' | 'TableStyleDark6' | 'TableStyleDark7' | 'TableStyleDark8' | 'TableStyleDark9' | 'TableStyleDark10' | 'TableStyleDark11' | 'TableStyleLight1' | 'TableStyleLight2' | 'TableStyleLight3' | 'TableStyleLight4' | 'TableStyleLight5' | 'TableStyleLight6' | 'TableStyleLight7' | 'TableStyleLight8' | 'TableStyleLight9' | 'TableStyleLight10' | 'TableStyleLight11' | 'TableStyleLight12' | 'TableStyleLight13' | 'TableStyleLight14' | 'TableStyleLight15' | 'TableStyleLight16' | 'TableStyleLight17' | 'TableStyleLight18' | 'TableStyleLight19' | 'TableStyleLight20' | 'TableStyleLight21' | 'TableStyleMedium1' | 'TableStyleMedium2' | 'TableStyleMedium3' | 'TableStyleMedium4' | 'TableStyleMedium5' | 'TableStyleMedium6' | 'TableStyleMedium7' | 'TableStyleMedium8' | 'TableStyleMedium9' | 'TableStyleMedium10' | 'TableStyleMedium11' | 'TableStyleMedium12' | 'TableStyleMedium13' | 'TableStyleMedium14' | 'TableStyleMedium15' | 'TableStyleMedium16' | 'TableStyleMedium17' | 'TableStyleMedium18' | 'TableStyleMedium19' | 'TableStyleMedium20' | 'TableStyleMedium21' | 'TableStyleMedium22' | 'TableStyleMedium23' | 'TableStyleMedium24' | 'TableStyleMedium25' | 'TableStyleMedium26' | 'TableStyleMedium27' | 'TableStyleMedium28';
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Describes which style is used to display this table, and specifies which portions of the table
|
|
428
|
+
* have which styles applied.
|
|
429
|
+
*/
|
|
430
|
+
type TableStyle = {
|
|
431
|
+
/**
|
|
432
|
+
* The name of the table style to use with this table.
|
|
433
|
+
*
|
|
434
|
+
* If the value is null or omitted the table should not be rendered with any special styling (note
|
|
435
|
+
* that this only applies if the style object itself is present).
|
|
436
|
+
* @default null
|
|
437
|
+
*/
|
|
438
|
+
name?: TableStyleName | null;
|
|
439
|
+
/**
|
|
440
|
+
* Whether row stripe formatting should be applied.
|
|
441
|
+
*
|
|
442
|
+
* @default true
|
|
443
|
+
*/
|
|
444
|
+
showRowStripes?: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Whether column stripe formatting should be applied.
|
|
447
|
+
*
|
|
448
|
+
* @default false
|
|
449
|
+
*/
|
|
450
|
+
showColumnStripes?: boolean;
|
|
451
|
+
/**
|
|
452
|
+
* Whether the first (leftmost) column in the table should be highlighted.
|
|
453
|
+
*
|
|
454
|
+
* @default false
|
|
455
|
+
*/
|
|
456
|
+
showFirstColumn?: boolean;
|
|
457
|
+
/**
|
|
458
|
+
* Whether the last (rightmost) column in the table should be highlighted.
|
|
459
|
+
*
|
|
460
|
+
* @default false
|
|
461
|
+
*/
|
|
462
|
+
showLastColumn?: boolean;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* A tabular data structure.
|
|
467
|
+
*
|
|
468
|
+
* The metadata contained in a table can be used to resolve structured references and evaluate
|
|
469
|
+
* calculated columns.
|
|
470
|
+
*
|
|
471
|
+
* @see {@link https://support.microsoft.com/office/f5ed2452-2337-4f71-bed3-c8ae6d2b276e}
|
|
472
|
+
*/
|
|
473
|
+
type Table = {
|
|
474
|
+
/**
|
|
475
|
+
* The name of the table. This name must adhere to the same restrictions as defined names in
|
|
476
|
+
* Excel. In particular, it cannot contain spaces.
|
|
477
|
+
*/
|
|
478
|
+
name: string;
|
|
479
|
+
/**
|
|
480
|
+
* The name of the sheet in which the table is located.
|
|
481
|
+
*/
|
|
482
|
+
sheet: string;
|
|
483
|
+
/**
|
|
484
|
+
* A non-prefixed range reference to the area containing the table. The range shall include the
|
|
485
|
+
* column headers.
|
|
486
|
+
*/
|
|
487
|
+
ref: CellRange;
|
|
488
|
+
/**
|
|
489
|
+
* An array of column objects. They shall be ordered from left to right, so that the first column
|
|
490
|
+
* corresponds to the leftmost column in the referenced range and the last column corresponds to
|
|
491
|
+
* the rightmost column.
|
|
492
|
+
*/
|
|
493
|
+
columns: TableColumn[];
|
|
494
|
+
/**
|
|
495
|
+
* A non-negative integer specifying the number of totals rows at the bottom of the table. Default
|
|
496
|
+
* to 0 if absent.
|
|
497
|
+
*
|
|
498
|
+
* @default 0
|
|
499
|
+
*/
|
|
500
|
+
totalsRowCount?: integer;
|
|
501
|
+
/**
|
|
502
|
+
* A non-negative integer specifying the number of header rows at the top of the table. Default to
|
|
503
|
+
* 1 if absent.
|
|
504
|
+
* @default 1
|
|
505
|
+
*/
|
|
506
|
+
headerRowCount?: integer;
|
|
507
|
+
/**
|
|
508
|
+
* Presentation information for the table. When not present tables should be rendered using
|
|
509
|
+
* `"TableStyleMedium2"` style with `showRowStripes` active.
|
|
510
|
+
*/
|
|
511
|
+
style?: TableStyle;
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* A collection of default properties that apply to cells, rows, or columns in the worksheet.
|
|
516
|
+
*/
|
|
517
|
+
type WorksheetDefaults = {
|
|
518
|
+
/** Default width of the UI-grid column. */
|
|
519
|
+
colWidth: PixelValue;
|
|
520
|
+
/** Default height of the UI-grid height. */
|
|
521
|
+
rowHeight: PixelValue;
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* A rectangle of cells. A sheet within a spreadsheet.
|
|
526
|
+
*/
|
|
527
|
+
type Worksheet = {
|
|
528
|
+
/** Name of the worksheet. */
|
|
529
|
+
name: string;
|
|
530
|
+
/** The cells belonging to the worksheet that have some data attached. */
|
|
531
|
+
cells: Record<CellId, Cell>;
|
|
532
|
+
/** Widths and styles of the columns in the worksheet. */
|
|
533
|
+
columns: GridSize[];
|
|
534
|
+
/** Heights and styles of the rows in the worksheet. */
|
|
535
|
+
rows: GridSize[];
|
|
536
|
+
/** Ranges that capture which cells have been merged. */
|
|
537
|
+
merges: string[];
|
|
538
|
+
/** A collection of default properties that apply to cells, rows, or columns in the worksheet. */
|
|
539
|
+
defaults: WorksheetDefaults;
|
|
540
|
+
/**
|
|
541
|
+
* Whether or not the sheet should be shown to a user in a UI displaying the workbook.
|
|
542
|
+
*
|
|
543
|
+
* - 0 = sheet is visible
|
|
544
|
+
* - 1 = sheet is hidden
|
|
545
|
+
* - 2 = sheet is "very hidden"
|
|
546
|
+
*
|
|
547
|
+
* @see {@link https://exceloffthegrid.com/make-excel-sheets-very-hidden/}
|
|
548
|
+
*/
|
|
549
|
+
hidden?: 0 | 1 | 2;
|
|
550
|
+
/** Indicates whether a hairline-grid should be drawn when displaying the sheet. */
|
|
551
|
+
showGridLines?: boolean;
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* A workbook is a collection of worksheets, styles, defined names, and other metadata. It's what's
|
|
556
|
+
* commonly known as a spreadsheet.
|
|
557
|
+
*/
|
|
558
|
+
type Workbook = {
|
|
559
|
+
/** Name of the workbook. In the case of a .xlsx file it will be the filename. */
|
|
560
|
+
name: string;
|
|
561
|
+
/** An ordered array of the worksheets in the workbook. */
|
|
562
|
+
sheets: Worksheet[];
|
|
563
|
+
/** An array of the workbook's defined names. */
|
|
564
|
+
names: DefinedName[];
|
|
565
|
+
/** Metadata on the workbook's tables. */
|
|
566
|
+
tables: Table[];
|
|
567
|
+
/** Directions on how formulas should be recalculated in the workbook. */
|
|
568
|
+
calculationProperties?: CalcProps;
|
|
569
|
+
/** Styles for cells in the workbook. */
|
|
570
|
+
styles: Style[];
|
|
571
|
+
/** External cells referenced by the workbook. An external cell is a cell in another workbook. */
|
|
572
|
+
externals?: External[];
|
|
573
|
+
/**
|
|
574
|
+
* Deduplicated formulas used in the workbook. Stored in R1C1 notation. Two formulas are
|
|
575
|
+
* considered to be the same when their respective representations in R1C1 notation, are
|
|
576
|
+
* identical.
|
|
577
|
+
*/
|
|
578
|
+
formulas?: string[];
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
export type { BorderStyle, CalcProps, Cell, CellId, CellRange, CellValueType, Color, Comment, DefinedName, External, ExternalWorksheet, GridSize, HAlign, PatternStyle, PixelValue, Style, Table, TableColumn, TableColumnDataType, TableStyle, TableStyleName, Underline, VAlign, Workbook, Worksheet, WorksheetDefaults };
|
package/dist/index.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jsfkit/types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A JSON representation for spreadsheets",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/jsfkit/types.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"excel",
|
|
13
|
+
"json",
|
|
14
|
+
"xlsx",
|
|
15
|
+
"jsf",
|
|
16
|
+
"spreadsheet",
|
|
17
|
+
"workbook",
|
|
18
|
+
"types",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup",
|
|
32
|
+
"check": "npm run lint && npm run typecheck",
|
|
33
|
+
"lint": "eslint src",
|
|
34
|
+
"format": "eslint src --fix",
|
|
35
|
+
"typecheck": "tsc",
|
|
36
|
+
"release": "PACKAGE_VERSION=$(jq -r .version package.json) && echo \"About to tag and push v$PACKAGE_VERSION. Continue? (y/n)\" && read -r REPLY && [ \"$REPLY\" = \"y\" ] && git tag --annotate v$PACKAGE_VERSION --message=v$PACKAGE_VERSION && git push origin v$PACKAGE_VERSION"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@borgar/eslint-config": "^4.0.0",
|
|
40
|
+
"@eslint/js": "^9.38.0",
|
|
41
|
+
"eslint": "^9.38.0",
|
|
42
|
+
"globals": "^16.4.0",
|
|
43
|
+
"tsup": "^8.5.0",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"typescript-eslint": "^8.46.1"
|
|
46
|
+
}
|
|
47
|
+
}
|