First fetch data from server then export xlsx file with same click
See original GitHub issueFirst I want to fetch data with API then that data should download with react-data-export. For this, I want to use single button for both work.
this time, I’m using like this -
<Button onClick={this.fetchData}>Fetch Data</Button>
fetchData() {
axios.get('api_link')
.then(({data}) => {
this.setState({data})
})
}
and then Download data -
<ExcelFile element={<button>Download Data</button>}>
<ExcelSheet data={data} name="Employees">
<ExcelColumn label="Name" value="name"/>
<ExcelColumn label="Wallet Money" value="amount"/>
<ExcelColumn label="Gender" value="sex"/>
<ExcelColumn label="Marital Status" value={(col) => col.is_married ? "Married" : "Single"}/>
</ExcelSheet>
</ExcelFile>
but Buttons will show 2 times. it’s not good looking for users.
So, How can I fetch and download data with only one click ?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
How to Export SQL Server Data to an Excel File
In Object Explorer, right-click the required database/table/view and click Export Data on the shortcut menu to invoke the export wizard. On its ...
Read more >3 Ways To Export an SQL Query to an Excel File using SQL ...
Right-click on the database you want to export from. Then Select tasks and “Export Data”. Export Data. The SQL Server Wizard will startup....
Read more >How to Import and Export SQL Server data to an Excel file
From the Select the database that contains the data you want drop down box, choose the database from which the data will be...
Read more >How to save .xlsx data to file as a blob - javascript
Here's my implementation using the fetch api. The server endpoint sends a stream of bytes and the client receives a byte array and...
Read more >Import from Excel or export to Excel with SSIS - SQL Server ...
Specify Excel as your data source. · Provide the Excel file name and path. · Select the Excel version. · Specify whether the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @securedeveloper, when I am trying to hide the button using ‘hideElement’ property. The excel file is downloading twice. Did you come across such king of issue?
@arpitprod after the first download => set state data = null. That is my trick.