New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set a filename when using CSVDownload #47
Comments
Yes, please on this feature.. |
Is this feature still ongoing? |
@abdennour will #69 resolve this? if so, when can this be merged. |
+1 on this feature too, really need to be able to set a filename ! |
is not work |
But I found a correct way, you can use replace. example: |
+1 on this feature |
This still doesn't work. Why wouldn't you have this feature on CSVDownload when you have it CSVLink? 2 years and still open? Please add it as a feature. 🙏 |
Can a maintainer update and merge #137 to fix this please? |
Here is a way around this issue by using refs. https://stackoverflow.com/questions/53504924/reactjs-download-csv-file-on-button-click |
I ended up copying "core" from the lib as "Core.js" and writing:
Works exactly as expected. |
Here's another drop-in replacement for import React, { useEffect, useRef } from 'react'
import { CSVLink } from 'react-csv'
const CSVDownload = (props) => {
const btnRef = useRef(null)
useEffect(() => btnRef.current?.click(), [btnRef])
return (
<CSVLink {...props}>
<span ref={btnRef} />
</CSVLink>
)
} |
This can help to solve the problem: |
Is there any solution for this? This issue has open in 2017!! |
@dhanushkakp I could not find a solution either so I created my own CSV Download functionality here: https://gist.github.com/cburkhardtBB/14ba0e3a37c2cef83eaea79e8c93092d It supports headers/no headers, file naming based on time, and is all done in less than 100 lines of code. |
abandoned? |
This workaround worked #47 (comment) |
The
filename
prop allows to set a custom filename to the CSV file, however it's available only when using the CSVLink component. Would be interesting to be able set a filename when using the CSVDownload component as well.The text was updated successfully, but these errors were encountered: