sheetra 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.
@@ -0,0 +1,288 @@
1
+ /**
2
+ * Cell value types supported by Sheetra
3
+ */
4
+ export type CellValueType = 'string' | 'number' | 'date' | 'boolean' | 'formula' | 'error';
5
+ /**
6
+ * Cell alignment options
7
+ */
8
+ export type HorizontalAlignment = 'left' | 'center' | 'right' | 'fill' | 'justify' | 'centerContinuous' | 'distributed';
9
+ export type VerticalAlignment = 'top' | 'middle' | 'bottom' | 'distributed' | 'justify';
10
+ /**
11
+ * Border style options
12
+ */
13
+ export type BorderStyleType = 'thin' | 'medium' | 'thick' | 'dotted' | 'dashed' | 'double' | 'hair' | 'mediumDashed' | 'dashDot' | 'mediumDashDot' | 'dashDotDot' | 'mediumDashDotDot' | 'slantDashDot';
14
+ /**
15
+ * Font styling options
16
+ */
17
+ export interface FontStyle {
18
+ /** Font name (e.g., 'Arial', 'Calibri') */
19
+ name?: string;
20
+ /** Font size in points */
21
+ size?: number;
22
+ /** Bold text */
23
+ bold?: boolean;
24
+ /** Italic text */
25
+ italic?: boolean;
26
+ /** Underline style */
27
+ underline?: boolean | 'single' | 'double' | 'singleAccounting' | 'doubleAccounting';
28
+ /** Strikethrough text */
29
+ strike?: boolean;
30
+ /** Font color in hex or RGB */
31
+ color?: string;
32
+ /** Font family */
33
+ family?: number;
34
+ /** Font scheme */
35
+ scheme?: 'major' | 'minor' | 'none';
36
+ /** Character set */
37
+ charset?: number;
38
+ /** Outline font */
39
+ outline?: boolean;
40
+ /** Shadow font */
41
+ shadow?: boolean;
42
+ /** Condense font */
43
+ condense?: boolean;
44
+ /** Extend font */
45
+ extend?: boolean;
46
+ /** Vertical alignment text */
47
+ verticalAlign?: 'superscript' | 'subscript' | 'baseline';
48
+ }
49
+ /**
50
+ * Border definition for a single side
51
+ */
52
+ export interface BorderEdge {
53
+ /** Border style */
54
+ style?: BorderStyleType;
55
+ /** Border color in hex or RGB */
56
+ color?: string;
57
+ }
58
+ /**
59
+ * Complete border configuration
60
+ */
61
+ export interface Border {
62
+ /** Top border */
63
+ top?: BorderEdge;
64
+ /** Bottom border */
65
+ bottom?: BorderEdge;
66
+ /** Left border */
67
+ left?: BorderEdge;
68
+ /** Right border */
69
+ right?: BorderEdge;
70
+ /** Diagonal border (top-left to bottom-right) */
71
+ diagonal?: BorderEdge;
72
+ /** Diagonal border (bottom-left to top-right) */
73
+ diagonalDown?: BorderEdge;
74
+ /** Diagonal border (top-right to bottom-left) */
75
+ diagonalUp?: BorderEdge;
76
+ /** Diagonal border type */
77
+ diagonalType?: 'both' | 'up' | 'down';
78
+ }
79
+ /**
80
+ * Fill pattern types
81
+ */
82
+ export type FillPattern = 'none' | 'solid' | 'gray125' | 'gray0625' | 'gray75' | 'gray50' | 'gray25' | 'gray12' | 'gray6' | 'horizontalStripe' | 'verticalStripe' | 'reverseDiagonalStripe' | 'diagonalStripe' | 'diagonalCrosshatch' | 'thickDiagonalCrosshatch' | 'thinHorizontalStripe' | 'thinVerticalStripe' | 'thinReverseDiagonalStripe' | 'thinDiagonalStripe' | 'thinHorizontalCrosshatch' | 'thinDiagonalCrosshatch';
83
+ /**
84
+ * Fill configuration for cell background
85
+ */
86
+ export interface Fill {
87
+ /** Fill pattern type */
88
+ patternType?: FillPattern;
89
+ /** Foreground color (pattern color) */
90
+ fgColor?: string;
91
+ /** Background color */
92
+ bgColor?: string;
93
+ }
94
+ /**
95
+ * Number format configuration
96
+ */
97
+ export interface NumberFormat {
98
+ /** Format code (e.g., '#,##0.00', '0%', 'm/d/yyyy') */
99
+ format: string;
100
+ /** Number of decimal places */
101
+ decimals?: number;
102
+ /** Thousands separator */
103
+ thousandsSeparator?: boolean;
104
+ /** Currency symbol */
105
+ currencySymbol?: string;
106
+ /** Negative number format */
107
+ negativeFormat?: 'parentheses' | 'minus' | 'red';
108
+ }
109
+ /**
110
+ * Complete cell style configuration
111
+ */
112
+ export interface CellStyle {
113
+ /** Font styling */
114
+ font?: FontStyle;
115
+ /** Border configuration */
116
+ border?: Border;
117
+ /** Fill configuration */
118
+ fill?: Fill;
119
+ /** Number format */
120
+ numberFormat?: string | NumberFormat;
121
+ /** Horizontal alignment */
122
+ alignment?: HorizontalAlignment;
123
+ /** Vertical alignment */
124
+ verticalAlignment?: VerticalAlignment;
125
+ /** Text wrapping */
126
+ wrapText?: boolean;
127
+ /** Text rotation in degrees */
128
+ textRotation?: number;
129
+ /** Indentation level */
130
+ indent?: number;
131
+ /** Shrink to fit */
132
+ shrinkToFit?: boolean;
133
+ /** Reading order */
134
+ readingOrder?: 'context' | 'leftToRight' | 'rightToLeft';
135
+ /** Hidden cell */
136
+ hidden?: boolean;
137
+ /** Locked cell (for protection) */
138
+ locked?: boolean;
139
+ bold?: boolean;
140
+ italic?: boolean;
141
+ underline?: boolean | 'single' | 'double' | 'singleAccounting' | 'doubleAccounting';
142
+ fontSize?: number;
143
+ fontFamily?: string;
144
+ color?: string;
145
+ backgroundColor?: string;
146
+ borderAll?: {
147
+ style: BorderStyleType;
148
+ color?: string;
149
+ };
150
+ }
151
+ /**
152
+ * Cell data structure
153
+ */
154
+ export interface CellData {
155
+ /** Cell value */
156
+ value: string | number | boolean | Date | null;
157
+ /** Cell style */
158
+ style?: CellStyle;
159
+ /** Cell formula (if any) */
160
+ formula?: string;
161
+ /** Cell value type */
162
+ type?: CellValueType;
163
+ /** Cell comment */
164
+ comment?: string;
165
+ /** Hyperlink */
166
+ hyperlink?: string;
167
+ /** Tooltip */
168
+ tooltip?: string;
169
+ /** Cell error value */
170
+ error?: string;
171
+ /** Shared formula reference */
172
+ sharedFormula?: string;
173
+ /** Array formula */
174
+ arrayFormula?: {
175
+ formula: string;
176
+ range: string;
177
+ };
178
+ /** Rich text (array of formatted text runs) */
179
+ richText?: Array<{
180
+ text: string;
181
+ font?: FontStyle;
182
+ }>;
183
+ }
184
+ /**
185
+ * Cell address (A1 notation)
186
+ */
187
+ export interface CellAddress {
188
+ /** Column name (A, B, C, etc.) */
189
+ column: string;
190
+ /** Row number (1-based) */
191
+ row: number;
192
+ /** Absolute column ($A) */
193
+ absoluteColumn?: boolean;
194
+ /** Absolute row ($1) */
195
+ absoluteRow?: boolean;
196
+ }
197
+ /**
198
+ * Cell range (A1:B2 notation)
199
+ */
200
+ export interface CellRange {
201
+ /** Start cell */
202
+ start: CellAddress;
203
+ /** End cell */
204
+ end: CellAddress;
205
+ }
206
+ /**
207
+ * Data validation rules
208
+ */
209
+ export interface DataValidation {
210
+ /** Validation type */
211
+ type: 'whole' | 'decimal' | 'list' | 'date' | 'time' | 'textLength' | 'custom';
212
+ /** Operator for comparison */
213
+ operator?: 'between' | 'notBetween' | 'equal' | 'notEqual' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual';
214
+ /** Formula 1 (value or range) */
215
+ formula1?: string | number;
216
+ /** Formula 2 (for between operators) */
217
+ formula2?: string | number;
218
+ /** Allow blank */
219
+ allowBlank?: boolean;
220
+ /** Show input message */
221
+ showInputMessage?: boolean;
222
+ /** Show error message */
223
+ showErrorMessage?: boolean;
224
+ /** Input title */
225
+ inputTitle?: string;
226
+ /** Input message */
227
+ inputMessage?: string;
228
+ /** Error title */
229
+ errorTitle?: string;
230
+ /** Error message */
231
+ errorMessage?: string;
232
+ /** Error style */
233
+ errorStyle?: 'stop' | 'warning' | 'information';
234
+ /** List of values (for list type) */
235
+ values?: any[];
236
+ /** Reference to list range */
237
+ listRange?: string;
238
+ }
239
+ /**
240
+ * Conditional formatting rule
241
+ */
242
+ export interface ConditionalFormatRule {
243
+ /** Rule type */
244
+ type: 'expression' | 'cellIs' | 'colorScale' | 'dataBar' | 'iconSet' | 'top10' | 'uniqueValues' | 'duplicateValues' | 'containsText' | 'notContainsText' | 'beginsWith' | 'endsWith' | 'containsBlanks' | 'notContainsBlanks' | 'containsErrors' | 'notContainsErrors' | 'timePeriod' | 'aboveAverage';
245
+ /** Priority of rule */
246
+ priority: number;
247
+ /** Stop if true */
248
+ stopIfTrue?: boolean;
249
+ /** Formula for expression type */
250
+ formula?: string;
251
+ /** Operator for cellIs type */
252
+ operator?: string;
253
+ /** Value for comparison */
254
+ value?: any;
255
+ /** Style to apply */
256
+ style?: CellStyle;
257
+ /** Format for data bars */
258
+ dataBar?: {
259
+ minLength?: number;
260
+ maxLength?: number;
261
+ showValue?: boolean;
262
+ gradient?: boolean;
263
+ border?: boolean;
264
+ negativeBarColor?: string;
265
+ axisColor?: string;
266
+ direction?: 'context' | 'leftToRight' | 'rightToLeft';
267
+ };
268
+ /** Format for color scales */
269
+ colorScale?: {
270
+ minColor?: string;
271
+ midColor?: string;
272
+ maxColor?: string;
273
+ };
274
+ /** Format for icon sets */
275
+ iconSet?: {
276
+ iconSet?: '3Arrows' | '3ArrowsGray' | '3Flags' | '3TrafficLights1' | '3TrafficLights2' | '3Signs' | '3Symbols' | '3Symbols2' | '4Arrows' | '4ArrowsGray' | '4RedToBlack' | '4Rating' | '4TrafficLights' | '5Arrows' | '5ArrowsGray' | '5Rating' | '5Quarters';
277
+ showValue?: boolean;
278
+ percent?: boolean;
279
+ reverse?: boolean;
280
+ };
281
+ }
282
+ /**
283
+ * Border style
284
+ */
285
+ export interface BorderStyle {
286
+ style: BorderStyleType;
287
+ color?: string;
288
+ }
@@ -0,0 +1,303 @@
1
+ import { Border, Fill } from "./cell.types";
2
+ /**
3
+ * Export options for exporting sheets, workbooks, etc.
4
+ */
5
+ export interface ExportOptions {
6
+ /** Output file name (with extension) */
7
+ filename?: string;
8
+ /** File format: 'xlsx', 'csv', 'json', etc. */
9
+ format?: 'xlsx' | 'csv' | 'json';
10
+ /** Whether to include styles in export */
11
+ includeStyles?: boolean;
12
+ /** Whether to include hidden rows/columns */
13
+ includeHidden?: boolean;
14
+ /** Password for protected export (if supported) */
15
+ password?: string;
16
+ /** Sheet name (for single-sheet export) */
17
+ sheetName?: string;
18
+ /** Locale for formatting */
19
+ locale?: string;
20
+ /** Custom options for writers */
21
+ [key: string]: any;
22
+ }
23
+ /**
24
+ * Chart series data
25
+ */
26
+ export interface ChartSeries {
27
+ /** Series name */
28
+ name?: string;
29
+ /** Categories (X-axis) */
30
+ categories?: any[];
31
+ /** Values (Y-axis) */
32
+ values: any[];
33
+ /** Series color */
34
+ color?: string;
35
+ /** Series style */
36
+ style?: number;
37
+ /** Marker style (for line charts) */
38
+ marker?: {
39
+ symbol?: 'circle' | 'diamond' | 'square' | 'triangle' | 'none';
40
+ size?: number;
41
+ fill?: string;
42
+ stroke?: string;
43
+ };
44
+ /** Trendline */
45
+ trendline?: {
46
+ type: 'linear' | 'exponential' | 'logarithmic' | 'polynomial' | 'movingAverage';
47
+ order?: number;
48
+ period?: number;
49
+ forward?: number;
50
+ backward?: number;
51
+ intercept?: number;
52
+ displayEquation?: boolean;
53
+ displayRSquared?: boolean;
54
+ name?: string;
55
+ };
56
+ /** Error bars */
57
+ errorBars?: {
58
+ type: 'fixed' | 'percentage' | 'standardDeviation' | 'standardError' | 'custom';
59
+ value?: number;
60
+ plusValues?: any[];
61
+ minusValues?: any[];
62
+ direction?: 'both' | 'plus' | 'minus';
63
+ endStyle?: 'cap' | 'noCap';
64
+ };
65
+ }
66
+ /**
67
+ * Chart axis configuration
68
+ */
69
+ export interface ChartAxis {
70
+ /** Axis title */
71
+ title?: string;
72
+ /** Minimum value */
73
+ min?: number;
74
+ /** Maximum value */
75
+ max?: number;
76
+ /** Major unit */
77
+ majorUnit?: number;
78
+ /** Minor unit */
79
+ minorUnit?: number;
80
+ /** Reverse order */
81
+ reverse?: boolean;
82
+ /** Logarithmic scale */
83
+ logarithmic?: boolean;
84
+ /** Base for logarithmic scale */
85
+ logBase?: number;
86
+ /** Format code */
87
+ format?: string;
88
+ /** Axis position */
89
+ position?: 'bottom' | 'left' | 'right' | 'top';
90
+ /** Crossing point */
91
+ crosses?: 'auto' | 'min' | 'max' | number;
92
+ /** Gridlines */
93
+ gridlines?: {
94
+ major?: boolean;
95
+ minor?: boolean;
96
+ color?: string;
97
+ };
98
+ /** Tick marks */
99
+ tickMarks?: {
100
+ major?: 'none' | 'inside' | 'outside' | 'cross';
101
+ minor?: 'none' | 'inside' | 'outside' | 'cross';
102
+ };
103
+ /** Font */
104
+ font?: {
105
+ name?: string;
106
+ size?: number;
107
+ bold?: boolean;
108
+ color?: string;
109
+ };
110
+ }
111
+ /**
112
+ * Complete chart configuration
113
+ */
114
+ export interface ChartConfig {
115
+ /** Chart title */
116
+ title?: string;
117
+ /** Chart type */
118
+ type: 'area' | 'bar' | 'column' | 'line' | 'pie' | 'doughnut' | 'radar' | 'scatter' | 'stock' | 'surface' | 'bubble' | 'radarArea' | 'radarLine' | 'radarFilled' | 'barStacked' | 'columnStacked' | 'barPercent' | 'columnPercent' | 'areaStacked' | 'areaPercent' | 'lineStacked' | 'linePercent' | 'pie3D' | 'bar3D' | 'column3D' | 'line3D' | 'area3D' | 'surface3D';
119
+ /** Chart sub-type */
120
+ subType?: 'clustered' | 'stacked' | 'percent' | '3D' | '3DClustered' | '3DStacked' | '3DPercent';
121
+ /** Data range */
122
+ dataRange?: string;
123
+ /** Series data */
124
+ series?: ChartSeries[];
125
+ /** X-axis configuration */
126
+ xAxis?: ChartAxis;
127
+ /** Y-axis configuration */
128
+ yAxis?: ChartAxis;
129
+ /** Secondary X-axis */
130
+ xAxis2?: ChartAxis;
131
+ /** Secondary Y-axis */
132
+ yAxis2?: ChartAxis;
133
+ /** Legend */
134
+ legend?: {
135
+ position?: 'top' | 'bottom' | 'left' | 'right' | 'corner' | 'none';
136
+ layout?: 'stack' | 'overlay';
137
+ showSeriesName?: boolean;
138
+ font?: {
139
+ name?: string;
140
+ size?: number;
141
+ bold?: boolean;
142
+ color?: string;
143
+ };
144
+ };
145
+ /** Data labels */
146
+ dataLabels?: {
147
+ show?: boolean;
148
+ position?: 'center' | 'insideEnd' | 'insideBase' | 'outsideEnd' | 'bestFit';
149
+ format?: string;
150
+ font?: {
151
+ name?: string;
152
+ size?: number;
153
+ bold?: boolean;
154
+ color?: string;
155
+ };
156
+ separator?: string;
157
+ showSeriesName?: boolean;
158
+ showCategoryName?: boolean;
159
+ showValue?: boolean;
160
+ showPercentage?: boolean;
161
+ showLeaderLines?: boolean;
162
+ };
163
+ /** Chart size in pixels */
164
+ size?: {
165
+ width: number;
166
+ height: number;
167
+ };
168
+ /** Chart position in pixels (from top-left of sheet) */
169
+ position?: {
170
+ x: number;
171
+ y: number;
172
+ };
173
+ /** Chart style (1-48) */
174
+ style?: number;
175
+ /** Chart template */
176
+ template?: string;
177
+ /** Gap width (for bar/column) */
178
+ gapWidth?: number;
179
+ /** Overlap (for bar/column) */
180
+ overlap?: number;
181
+ /** Vary colors by point */
182
+ varyColors?: boolean;
183
+ /** Smooth lines */
184
+ smooth?: boolean;
185
+ /** Show data table */
186
+ dataTable?: {
187
+ show?: boolean;
188
+ showLegendKeys?: boolean;
189
+ border?: boolean;
190
+ font?: {
191
+ name?: string;
192
+ size?: number;
193
+ bold?: boolean;
194
+ color?: string;
195
+ };
196
+ };
197
+ /** 3D options */
198
+ threeD?: {
199
+ rotation?: number;
200
+ perspective?: number;
201
+ height?: number;
202
+ depth?: number;
203
+ rightAngleAxes?: boolean;
204
+ lighting?: boolean;
205
+ };
206
+ /** Plot area */
207
+ plotArea?: {
208
+ border?: Border;
209
+ fill?: Fill;
210
+ transparency?: number;
211
+ };
212
+ /** Chart area */
213
+ chartArea?: {
214
+ border?: Border;
215
+ fill?: Fill;
216
+ transparency?: number;
217
+ };
218
+ }
219
+ /**
220
+ * Drawing object (image, shape, etc.)
221
+ */
222
+ export interface Drawing {
223
+ /** Drawing type */
224
+ type: 'image' | 'shape' | 'chart' | 'smartArt';
225
+ /** Drawing position */
226
+ from: {
227
+ col: number;
228
+ row: number;
229
+ colOffset?: number;
230
+ rowOffset?: number;
231
+ };
232
+ /** Drawing size */
233
+ to?: {
234
+ col: number;
235
+ row: number;
236
+ colOffset?: number;
237
+ rowOffset?: number;
238
+ };
239
+ /** Image data (for images) */
240
+ image?: {
241
+ data: string | ArrayBuffer;
242
+ format: 'png' | 'jpg' | 'gif' | 'bmp' | 'svg';
243
+ name?: string;
244
+ description?: string;
245
+ };
246
+ /** Shape data (for shapes) */
247
+ shape?: {
248
+ type: 'rectangle' | 'ellipse' | 'triangle' | 'line' | 'arrow' | 'callout' | 'flowchart' | 'star' | 'banner';
249
+ text?: string;
250
+ fill?: Fill;
251
+ border?: Border;
252
+ rotation?: number;
253
+ flipHorizontal?: boolean;
254
+ flipVertical?: boolean;
255
+ };
256
+ /** Chart reference */
257
+ chart?: ChartConfig;
258
+ /** Alternative text */
259
+ altText?: string;
260
+ /** Hyperlink */
261
+ hyperlink?: string;
262
+ /** Lock aspect ratio */
263
+ lockAspect?: boolean;
264
+ /** Lock position */
265
+ lockPosition?: boolean;
266
+ /** Print object */
267
+ print?: boolean;
268
+ /** Hidden */
269
+ hidden?: boolean;
270
+ }
271
+ /**
272
+ * Section configuration for export (e.g., for splitting sheets into sections)
273
+ */
274
+ export interface SectionConfig {
275
+ /** Section title */
276
+ title?: string;
277
+ /** Section description */
278
+ description?: string;
279
+ /** Range of rows included in this section (e.g., "A1:D10") */
280
+ range?: string;
281
+ /** Whether the section is collapsible */
282
+ collapsible?: boolean;
283
+ /** Whether the section is initially collapsed */
284
+ collapsed?: boolean;
285
+ /** Custom styles for the section */
286
+ style?: {
287
+ backgroundColor?: string;
288
+ fontColor?: string;
289
+ fontSize?: number;
290
+ bold?: boolean;
291
+ italic?: boolean;
292
+ border?: Border;
293
+ fill?: Fill;
294
+ };
295
+ /** Additional custom options */
296
+ [key: string]: any;
297
+ }
298
+ /**
299
+ * Export filters
300
+ */
301
+ export interface ExportFilters {
302
+ [key: string]: any;
303
+ }
@@ -0,0 +1,13 @@
1
+ export * from './workbook.types';
2
+ export * from './cell.types';
3
+ import { CellStyle, Border, BorderStyle } from './cell.types';
4
+ import { WorkbookData, WorksheetData, RowData, ColumnData } from './workbook.types';
5
+ import { ExportOptions, SectionConfig, Drawing, ExportFilters } from './export.types';
6
+ export type { CellStyle, Border, BorderStyle, WorkbookData, WorksheetData, RowData, ColumnData, ExportOptions, SectionConfig, Drawing, ExportFilters };
7
+ export type DeepPartial<T> = {
8
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
9
+ };
10
+ export type Nullable<T> = T | null | undefined;
11
+ export type Record = {
12
+ [key: string]: unknown;
13
+ };