Skip to content

Commit f6f4d81

Browse files
authored
Merge pull request ghiscoding#139 from ghiscoding/bugfix/instruction-numbers
fix: ExcelStyleInstruction props can also be numbers
2 parents 27c4995 + d9c0987 commit f6f4d81

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

packages/excel-builder-vanilla-types/dist/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,13 @@ export interface ExcelSortState {
413413
export interface ExcelStyleInstruction {
414414
id?: number;
415415
alignment?: ExcelAlignmentStyle;
416-
border?: ExcelBorderStyle;
416+
border?: ExcelBorderStyle | number;
417417
borderId?: number;
418-
fill?: ExcelFillStyle;
418+
fill?: ExcelFillStyle | number;
419419
fillId?: number;
420-
font?: ExcelFontStyle;
420+
font?: ExcelFontStyle | number;
421421
fontId?: number;
422-
format?: string;
422+
format?: string | number;
423423
height?: number;
424424
numFmt?: string;
425425
numFmtId?: number;

packages/excel-builder-vanilla/src/Excel/StyleSheet.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class StyleSheet {
107107
if (styleInstructions.font && isObject(styleInstructions.font)) {
108108
style.fontId = this.createFontStyle(styleInstructions.font).id;
109109
} else if (styleInstructions.font) {
110-
if (Number.isNaN(Number.parseInt(styleInstructions.font, 10))) {
110+
if (Number.isNaN(Number.parseInt(styleInstructions.font as unknown as string, 10))) {
111111
throw new Error('Passing a non-numeric font id is not supported');
112112
}
113113
style.fontId = styleInstructions.font;
@@ -116,7 +116,7 @@ export class StyleSheet {
116116
if (styleInstructions.format && isString(styleInstructions.format)) {
117117
style.numFmtId = this.createNumberFormatter(styleInstructions.format).id;
118118
} else if (styleInstructions.format) {
119-
if (Number.isNaN(Number.parseInt(styleInstructions.format, 10))) {
119+
if (Number.isNaN(Number.parseInt(styleInstructions.format as unknown as string, 10))) {
120120
throw new Error('Invalid number formatter id');
121121
}
122122
style.numFmtId = styleInstructions.format;
@@ -125,7 +125,7 @@ export class StyleSheet {
125125
if (styleInstructions.border && isObject(styleInstructions.border)) {
126126
style.borderId = this.createBorderFormatter(styleInstructions.border).id;
127127
} else if (styleInstructions.border) {
128-
if (Number.isNaN(Number.parseInt(styleInstructions.border, 10))) {
128+
if (Number.isNaN(Number.parseInt(styleInstructions.border as unknown as string, 10))) {
129129
throw new Error('Passing a non-numeric border id is not supported');
130130
}
131131
style.borderId = styleInstructions.border;
@@ -134,7 +134,7 @@ export class StyleSheet {
134134
if (styleInstructions.fill && isObject(styleInstructions.fill)) {
135135
style.fillId = this.createFill(styleInstructions.fill).id;
136136
} else if (styleInstructions.fill) {
137-
if (Number.isNaN(Number.parseInt(styleInstructions.fill, 10))) {
137+
if (Number.isNaN(Number.parseInt(styleInstructions.fill as unknown as string, 10))) {
138138
throw new Error('Passing a non-numeric fill id is not supported');
139139
}
140140
style.fillId = styleInstructions.fill;

packages/excel-builder-vanilla/src/interfaces.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ export interface ExcelSortState {
124124
export interface ExcelStyleInstruction {
125125
id?: number;
126126
alignment?: ExcelAlignmentStyle;
127-
border?: ExcelBorderStyle;
127+
border?: ExcelBorderStyle | number;
128128
borderId?: number;
129-
fill?: ExcelFillStyle;
129+
fill?: ExcelFillStyle | number;
130130
fillId?: number;
131-
font?: ExcelFontStyle;
131+
font?: ExcelFontStyle | number;
132132
fontId?: number;
133-
format?: string;
133+
format?: string | number;
134134
height?: number;
135135
numFmt?: string;
136136
numFmtId?: number;

0 commit comments

Comments
 (0)