简体   繁体   中英

ReactJS components for PDF export, Excel export and print

I´m building some ReactJS Table and Report components tha basically will contain <table> data, some graphics ( d3 ) and some textual data. I need to provide 3 buttons:

  1. Export to PDF
  2. Export to Excel
  3. Print

Are there any trustable packages available for the tasks above using ReactJS ? What is the approach to handle these requirements ?

I would use a combination of the following JavaScript libraries:

React Csv is my favourite JavaScript library for working with csv. It excels at dynamic generation.

PDF Make is my favourite JavaScript library for generating PDFs.

Note: I would attach the files to this post, but there is currently no facility for this in StackOverflow.

  1. react-pdf (published 16 days ago - not tested)
  2. react-export-excel (published 8 months ago - not tested)
  3. For printing, put window.print() in your code

Example: Copy and paste this as .html (in React, it would be onClick={window.print()} ... If I'm correct)

<!Doctype html>
<html>
  <body>
    <p>Use the button below to print</p>
    <button id="print" onclick="window.print()">Print</button>
  </body>
</html>

Old question, but since I was looking for something similar, I ended up using :

  1. jspdf (see specific issue for reactjs )
  2. react-excel-workbook
  3. nothing yet, feel free to update the answer if you have.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM