Skip to content

Commit 3dc8863

Browse files
committed
0.7.1 - Extract several types into interfaces.
1 parent 9a1e834 commit 3dc8863

File tree

6 files changed

+59
-42
lines changed

6 files changed

+59
-42
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ This project does its best to adhere to [Semantic Versioning](http://semver.org/
44

55

66
--------
7-
### [0.7.0](N/A) - 2021-06-12
7+
### [0.7.1](N/A) - 2021-07-08
8+
#### Changed
9+
* Extract several parameter and field types into public interfaces
10+
11+
12+
--------
13+
### [0.7.0](https://github.com/TeamworkGuy2/excel-builder-ts/commit/9a1e834a13c844fc4cdc944e8b8409c3695207ef) - 2021-06-12
814
#### Changed
915
* Update to TypeScript 4.3
1016

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "excel-builder-ts",
3-
"version": "0.7.0",
3+
"version": "0.7.1",
44
"description": "TypeScript Port of excel-builder.js - A way to build excel files with javascript",
55
"author": "TeamworkGuy2",
66
"homepage": "https://github.com/TeamworkGuy2/excel-builder-ts",

workbook/Workbook.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,7 @@ class Workbook {
3737
worksheets: Worksheet[];
3838
tables: Workbook.Table[];
3939
drawings: Workbook.Drawing[];
40-
media: {
41-
[id: string]: {
42-
id: string;
43-
data: any;
44-
fileName: string;
45-
contentType: string;
46-
extension: string;
47-
}
48-
};
40+
media: { [id: string]: Workbook.Media };
4941
printTitles: {
5042
[sheetName: string]: {
5143
top?: number;
@@ -529,6 +521,15 @@ module Workbook {
529521
toXML(): string;
530522
}
531523

524+
525+
export interface Media {
526+
id: string;
527+
data: any;
528+
fileName: string;
529+
contentType: string;
530+
extension: string;
531+
}
532+
532533
}
533534

534535
export = Workbook;

worksheet/StyleSheet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ var StyleSheet = /** @class */ (function () {
349349
return records;
350350
};
351351
StyleSheet.prototype.exportCellFormatElement = function (doc, styleInstructions) {
352-
var xf = doc.createElement("xf"), i = 0;
352+
var xf = doc.createElement("xf");
353353
var allowed = ["applyAlignment", "applyBorder", "applyFill", "applyFont", "applyNumberFormat",
354354
"applyProtection", "borderId", "fillId", "fontId", "numFmtId", "pivotButton", "quotePrefix", "xfId"];
355355
var attributes = Object.keys(styleInstructions).filter(function (key) { return allowed.indexOf(key) != -1; });

worksheet/StyleSheet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class StyleSheet {
396396

397397

398398
public exportCellFormatElement(doc: XmlDom, styleInstructions: StyleSheet.CellFormat) {
399-
var xf = doc.createElement("xf"), i = 0;
399+
var xf = doc.createElement("xf");
400400
var allowed = ["applyAlignment", "applyBorder", "applyFill", "applyFont", "applyNumberFormat",
401401
"applyProtection", "borderId", "fillId", "fontId", "numFmtId", "pivotButton", "quotePrefix", "xfId"]
402402
var attributes = <(keyof StyleSheet.CellFormat)[]>Object.keys(styleInstructions).filter((key) => allowed.indexOf(key) != -1);

worksheet/Worksheet.ts

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,9 @@ class Worksheet {
3939
/** An array of attributes to apply to the 'pageSetup' element of the spreadsheet */
4040
pageSetup: { [prop: string]: any } | null;
4141
/** An array of attributes (only "ref" Ex: "A1:D1" for now) to apply to the autoFilter element of the spreadsheet. Only one autoFilter per Worksheet */
42-
autoFilter: {
43-
/** Letter portion of cell name that defines left to right where filter database starts at */
44-
left: string;
45-
/** Letter portion of cell name that defines left to right where filter database ends at */
46-
right: string;
47-
/** Row Number autFilter is applied to */
48-
rowNum: number;
49-
} | null;
42+
autoFilter: Worksheet.AutoFilter | null;
5043
/** An array of attributes to apply to the 'extLst' element of a worksheet. Used for creating "Data Validations" or drop downs with specific data sets. */
51-
dataValidations: {
52-
/** cell where data validation drop down is */
53-
sqref: string;
54-
/** sheet where data is stored */
55-
dataSheetName: string;
56-
/** Column where data set sits */
57-
column: string;
58-
/** Row where data set starts */
59-
topRow: number;
60-
/** Row where data set ends */
61-
bottomRow: number;
62-
}[] | null;
44+
dataValidations: Worksheet.DataValidation[] | null;
6345

6446

6547
/**
@@ -150,18 +132,12 @@ class Worksheet {
150132
//}
151133

152134

153-
public setAutoFilter(autoFilter: { left: string; right: string; rowNum: number } | null) {
135+
public setAutoFilter(autoFilter: Worksheet.AutoFilter | null) {
154136
this.autoFilter = autoFilter;
155137
}
156138

157139

158-
public setDataValidations(dataValidations: {
159-
sqref: string;
160-
dataSheetName: string;
161-
column: string;
162-
topRow: number;
163-
bottomRow: number;
164-
}[]) {
140+
public setDataValidations(dataValidations: Worksheet.DataValidation[]) {
165141
this.dataValidations = dataValidations;
166142
}
167143

@@ -216,7 +192,7 @@ class Worksheet {
216192
* @param piece
217193
* @returns string | reduce
218194
*/
219-
public compilePageDetailPiece(piece: string | { font?: number; bold?: boolean; underline?: boolean; fontSize?: number; text?: string; [id: string]: any } | any[]): string {
195+
public compilePageDetailPiece(piece: string | Worksheet.PageDetailPiece | Worksheet.PageDetailPiece[]): string {
220196
if (typeof piece === "string") {
221197
return '&"-,Regular"'.concat(piece);
222198
}
@@ -700,6 +676,16 @@ class Worksheet {
700676

701677
module Worksheet {
702678

679+
export interface AutoFilter {
680+
/** Letter portion of cell name that defines left to right where filter database starts at */
681+
left: string;
682+
/** Letter portion of cell name that defines left to right where filter database ends at */
683+
right: string;
684+
/** Row Number autFilter is applied to */
685+
rowNum: number;
686+
}
687+
688+
703689
export interface Column {
704690
min?: number;
705691
max?: number;
@@ -724,6 +710,20 @@ module Worksheet {
724710
}
725711

726712

713+
export interface DataValidation {
714+
/** cell where data validation drop down is */
715+
sqref: string;
716+
/** sheet where data is stored */
717+
dataSheetName: string;
718+
/** Column where data set sits */
719+
column: string;
720+
/** Row where data set starts */
721+
topRow: number;
722+
/** Row where data set ends */
723+
bottomRow: number;
724+
}
725+
726+
727727
export interface ExportData {
728728
id: string;
729729
name: string;
@@ -749,6 +749,16 @@ module Worksheet {
749749
footer?: string | number;
750750
}
751751

752+
753+
export interface PageDetailPiece {
754+
font?: number;
755+
bold?: boolean;
756+
underline?: boolean;
757+
fontSize?: number;
758+
text?: string;
759+
[id: string]: any;
760+
}
761+
752762
}
753763

754764
export = Worksheet;

0 commit comments

Comments
 (0)