'Is there any way we can export the Antd table data into an excel sheet on button click with reactjs

I am new to reactjs. I got a scenario in which the Antd table data need to be exported to an excel sheet on a button click. Is there any default options available with Antd? or we need to do some custom development for same. Any pointers will be appreciated.

Thanks



Solution 1:[1]

You can use library react-csv to convert the table data into an .csv file. You can refer to the docs for the onClick props.

import { CSVLink } from "react-csv";
            
    <CSVLink
        data={data}
        onClick={() => {
        console.log("clicked") 
        }}
    >
    Download me
    </CSVLink>
        
    <Table
       columns={columns}
       dataSource={data}
    />

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mohit gupta