File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
src/ExcelPlugin/components Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ node_modules
4
4
.idea /
5
5
.nyc_output /
6
6
coverage /
7
+ dist /ExcelPlugin
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ npm install react-data-export --save
26
26
27
27
## Excel Props
28
28
| Prop | Type | Default | Required | Description
29
- | :------------ | :------------------- | :--------- | :------- | :-------------------------------
29
+ | :------------ | :------------------- | :--------- | :------- | :-------------------------------------------------
30
+ | hideElement | ` bool ` | false | ` false ` | To hide the button & directly download excel file
30
31
| filename | ` string ` | Download | ` false ` | Excel file name to be downloaded
31
32
| fileExtension | ` string ` | xlsx | ` false ` | Download file extension [ xlsx]
32
33
| element | ` HTMLElement ` | ` <button> ` | ` false ` | Element to download excel file
@@ -40,7 +41,7 @@ npm install react-data-export --save
40
41
| dataSet | ` array<ExcelSheetData> ` | ` null ` | ` false ` | Excel Sheet data
41
42
| children | ` ExcelColumn ` | ` null ` | ` false ` | ExcelColumns
42
43
43
- ** Note:** In ExcelSheet props ` dataSet ` has ` presedence ` over ` data ` and ` children ` props.
44
+ ** Note:** In ExcelSheet props ` dataSet ` has ` precedence ` over ` data ` and ` children ` props.
44
45
45
46
For further types and definitions [ Read More] ( types/types.md )
46
47
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class ExcelFile extends React.Component {
11
11
defaultFileExtension = 'xlsx' ;
12
12
13
13
static props = {
14
+ hideElement : PropTypes . bool ,
14
15
filename : PropTypes . string ,
15
16
fileExtension : PropTypes . string ,
16
17
element : PropTypes . any ,
@@ -24,6 +25,7 @@ class ExcelFile extends React.Component {
24
25
} ;
25
26
26
27
static defaultProps = {
28
+ hideElement : false ,
27
29
filename : "Download" ,
28
30
fileExtension : "xlsx" ,
29
31
element : < button > Download</ button >
@@ -32,7 +34,12 @@ class ExcelFile extends React.Component {
32
34
constructor ( props ) {
33
35
super ( props ) ;
34
36
35
- this . handleDownload = this . download . bind ( this ) ;
37
+ if ( this . props . hideElement ) {
38
+ this . download ( ) ;
39
+ } else {
40
+ this . handleDownload = this . download . bind ( this ) ;
41
+ }
42
+
36
43
this . createSheetData = this . createSheetData . bind ( this ) ;
37
44
}
38
45
@@ -107,7 +114,14 @@ class ExcelFile extends React.Component {
107
114
}
108
115
109
116
render ( ) {
110
- return ( < span onClick = { this . handleDownload } > { this . props . element } </ span > ) ;
117
+ const { hideElement, element } = this . props ;
118
+
119
+ if ( props . hideElement ) {
120
+ return null ;
121
+ } else {
122
+ return ( < span onClick = { this . handleDownload } > { element } </ span > ) ;
123
+ }
124
+
111
125
}
112
126
}
113
127
You can’t perform that action at this time.
0 commit comments