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
44.idea /
55.nyc_output /
66coverage /
7+ dist /ExcelPlugin
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ npm install react-data-export --save
2626
2727## Excel Props
2828| Prop | Type | Default | Required | Description
29- | :------------ | :------------------- | :--------- | :------- | :-------------------------------
29+ | :------------ | :------------------- | :--------- | :------- | :-------------------------------------------------
30+ | hideElement | ` bool ` | false | ` false ` | To hide the button & directly download excel file
3031| filename | ` string ` | Download | ` false ` | Excel file name to be downloaded
3132| fileExtension | ` string ` | xlsx | ` false ` | Download file extension [ xlsx]
3233| element | ` HTMLElement ` | ` <button> ` | ` false ` | Element to download excel file
@@ -40,7 +41,7 @@ npm install react-data-export --save
4041| dataSet | ` array<ExcelSheetData> ` | ` null ` | ` false ` | Excel Sheet data
4142| children | ` ExcelColumn ` | ` null ` | ` false ` | ExcelColumns
4243
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.
4445
4546For further types and definitions [ Read More] ( types/types.md )
4647
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class ExcelFile extends React.Component {
1111 defaultFileExtension = 'xlsx' ;
1212
1313 static props = {
14+ hideElement : PropTypes . bool ,
1415 filename : PropTypes . string ,
1516 fileExtension : PropTypes . string ,
1617 element : PropTypes . any ,
@@ -24,6 +25,7 @@ class ExcelFile extends React.Component {
2425 } ;
2526
2627 static defaultProps = {
28+ hideElement : false ,
2729 filename : "Download" ,
2830 fileExtension : "xlsx" ,
2931 element : < button > Download</ button >
@@ -32,7 +34,12 @@ class ExcelFile extends React.Component {
3234 constructor ( props ) {
3335 super ( props ) ;
3436
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+
3643 this . createSheetData = this . createSheetData . bind ( this ) ;
3744 }
3845
@@ -107,7 +114,14 @@ class ExcelFile extends React.Component {
107114 }
108115
109116 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+
111125 }
112126}
113127
You can’t perform that action at this time.
0 commit comments