Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
cómo exportar los datos de la tabla de retorno a un archivo csv usando reaccionar js

Soy nuevo en React js.

Estoy tratando de exportar los datos tabulares devueltos a un archivo csv con un clic de botón.

 let names = [ {firstName: 'John',lastName: 'Cena'}, {firstName: 'Rey',lastName: 'Mysterio'}, ] const App = props => { return ( <div> {names.length > 0 && <table> //table renders only when array has elements <tbody> <tr> <th>First Name</th> //setting headers <th>Last Name</th> </tr> {names.map((name,index) => { //mapping for individual rows return ( <tr key={index}> <td>{name.firstName}</td> <td>{name.lastName}</td> </tr> ) })} </tbody> </table>} </div> ); };

Quiero crear un botón llamado exportar, y luego debería descargar los datos de la tabla que se devuelven a un archivo csv.

Cualquier ayuda es muy apreciada. Gracias.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Una biblioteca como react-csv lo ayudará a exportar datos a un archivo csv fácilmente, aquí hay un ejemplo:

 import { CSVLink, CSVDownload } from "react-csv"; let names = [ {firstName: 'John',lastName: 'Cena'}, {firstName: 'Rey',lastName: 'Mysterio'}, ] const App = props => { return ( <> <CSVLink data={names}>Download me</CSVLink>; // or <CSVDownload data={names} target="_blank" />; </> ); };

Para obtener más información sobre la biblioteca, visite: https://www.npmjs.com/package/react-csv

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!