0

I currently have a React app that uses the module CSVLink from react-csv to export data using a button.

import React from 'react';
import { CSVLink } from "react-csv";

export default function DownloadButtonMeeting({ new_data, headers, file }) {
    return (
        <div style={{ marginLeft: "10px" }}>
            <CSVLink data={new_data} headers={headers} className="btn" style={{ padding: "2px" }} filename={`${file}_summary.csv`}>Download</CSVLink>
        </div>
    )
}

It takes data, a fileName, and headers in an array object and exports to CSV on clicking the button.

export default function ContactsCard({ contactData }) {
    const contact_headers = [
        { label: "Name", key: "contact" },
        { label: "Title", key: "contact_title" },
        { label: "Email", key: "contact_email" },
        { label: "Phone", key: "contact_phone" },
        { label: "County", key: "county" },
        { label: "Affiliation", key: "affiliation" }
    ];
    
     const fileName = "Contact";
     return (
        <div>
         ....
            <DownloadButton new_data={[contactData]} headers={contact_headers} file={fileName} />     
        </div>
    )
}
         

Now, I've been tasked with basically taking multiple datasets/sheets and exporting as a single Excel file with multiple sheets. As far as I know, you can't do this with the csv format or react-csv. What are my best option for achieving this within React? Are there any React-Native solutions?

gwydion93
  • 1,681
  • 3
  • 28
  • 59

0 Answers0