Skip to content

Commit 21f03da

Browse files
committed
1 parent c8fc57d commit 21f03da

File tree

2 files changed

+146
-2
lines changed

2 files changed

+146
-2
lines changed

dist/index.d.ts

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/* index.d.ts (C) react-data-export */
2+
3+
// TypeScript Version: 2.2
4+
declare module 'react-data-export' {
5+
import * as React from 'react';
6+
7+
export interface ExcelFileProps {
8+
filename?: string;
9+
fileExtension?: string;
10+
element?: any; //Download Element
11+
children?: Array<React.ReactElement> | React.ReactElement; // Array<ExcelSheetProps>;
12+
}
13+
14+
export interface ExcelSheetProps {
15+
name: string;
16+
data?: Array<object>;
17+
dataSet?: Array<ExcelSheetData>;
18+
value?: Array<string> | Function;
19+
children?: Array<React.ReactElement> | React.ReactElement; // Array<ExcelColumnProps>
20+
}
21+
22+
export interface ExcelSheetData {
23+
xSteps?: number;
24+
ySteps?: number;
25+
columns: Array<string> | Array<ExcelCellHeader>;
26+
data: Array<Array<ExcelCellData>>;
27+
}
28+
29+
export type ExcelCellData = ExcelValue | ExcelCell | Array<ExcelValue>;
30+
export type ExcelValue = string | number | Date | boolean;
31+
32+
export interface ExcelCellHeader {
33+
title: string;
34+
style?: ExcelStyle;
35+
}
36+
37+
export interface ExcelCell {
38+
value: ExcelValue;
39+
style?: ExcelStyle;
40+
}
41+
42+
export interface ExcelColumnProps {
43+
label: string;
44+
value: number | boolean | string | Function;
45+
}
46+
47+
export interface ExcelStyle {
48+
fill?: ExcelCellFillType;
49+
font?: ExcelFont;
50+
numFmt?: ExcelNumFormat;
51+
alignment?: ExcelAlignment;
52+
border?: ExcelBorder;
53+
}
54+
55+
/* ExcelCell Fill Type */
56+
export type ExcelCellPatternType = "solid" | "none";
57+
58+
export interface ExcelColorSpec {
59+
auto?: number; //default 1
60+
rgb?: string; //hex ARGB color
61+
theme?: ExcelTheme;
62+
indexed?: number;
63+
}
64+
65+
export interface ExcelTheme {
66+
theme: string;
67+
tint: string;
68+
}
69+
70+
export interface ExcelCellFillType {
71+
patternType?: ExcelCellPatternType;
72+
fgColor?: ExcelColorSpec;
73+
bgColor?: ExcelColorSpec;
74+
}
75+
76+
/* Excel Font */
77+
export interface ExcelFont {
78+
name?: string; // default `"Calibri"`
79+
sz?: number; //font size in points default 11
80+
color?: ExcelColorSpec;
81+
bold?: boolean;
82+
underline?: boolean;
83+
italic?: boolean;
84+
strike?: boolean;
85+
outline?: boolean;
86+
shadow?: boolean;
87+
vertAlign?: boolean;
88+
}
89+
90+
/* ExcelNumFormat */
91+
export type ExcelNumFormat = "0" | "0.00%" | "0.0%" | "0.00%;\\(0.00%\\);\\-;@" | "m/dd/yy" | string;
92+
93+
/* ExcelAlignment */
94+
export interface ExcelAlignment {
95+
vertical?: ExcelAlignmentType;
96+
horizontal?: ExcelAlignmentType;
97+
wrapText?: boolean;
98+
readingOrder?: ExcelReadingOrder;
99+
textRotation?: ExcelTextRotation;
100+
}
101+
102+
export type ExcelTextRotation = 0 | 45 | 90 | 135 | 180 | 255;
103+
104+
export enum ExcelReadingOrder { LeftToRight = 1, RightToLeft}
105+
106+
export type ExcelAlignmentType = "bottom" | "center" | "top";
107+
108+
/* ExcelBorder */
109+
export interface ExcelBorder {
110+
style: ExcelBorderStyle;
111+
color: ExcelColorSpec;
112+
}
113+
114+
export type ExcelBorderStyle =
115+
"thin"
116+
| "medium"
117+
| "thick"
118+
| "dotted"
119+
| "hair"
120+
| "dashed"
121+
| "mediumDashed"
122+
| "dashDot"
123+
| "mediumDashDot"
124+
| "dashDotDot"
125+
| "mediumDashDotDot"
126+
| "slantDashDot";
127+
128+
export class ExcelColumn extends React.Component<ExcelColumnProps, any> {
129+
}
130+
131+
export class ExcelSheet extends React.Component<ExcelSheetProps, any> {
132+
}
133+
134+
export class ExcelFile extends React.Component<ExcelFileProps, any> {
135+
}
136+
137+
export namespace ReactExport {
138+
export class ExcelFile extends React.Component<ExcelFileProps, any> {
139+
static ExcelSheet: React.ElementType<ExcelSheetProps>;
140+
static ExcelColumn: React.ElementType<ExcelColumnProps>;
141+
}
142+
}
143+
export default ReactExport
144+
}

types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* index.d.ts (C) react-data-export */
22

33
// TypeScript Version: 2.2
4-
declare module 'react-data-export' {
4+
// declare module 'react-data-export' {
55
import * as React from 'react';
66

77
export interface ExcelFileProps {
@@ -141,4 +141,4 @@ declare module 'react-data-export' {
141141
}
142142
}
143143
export default ReactExport
144-
}
144+
// }

0 commit comments

Comments
 (0)