简体   繁体   English

用于PDF导出,Excel导出和打印的ReactJS组件

[英]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. 我正在构建一些ReactJS TableReport组件,它基本上将包含<table>数据,一些图形( d3 )和一些文本数据。 I need to provide 3 buttons: 我需要提供3个按钮:

  1. Export to PDF 导出为PDF
  2. Export to Excel 导出到Excel
  3. Print 打印

Are there any trustable packages available for the tasks above using ReactJS ? 使用ReactJS是否有任何可信任的包可用于上述任务? What is the approach to handle these requirements ? 处理这些要求的方法是什么?

I would use a combination of the following JavaScript libraries: 我将使用以下JavaScript库的组合:

React Csv is my favourite JavaScript library for working with csv. React Csv是我最喜欢的用于处理csv的JavaScript库。 It excels at dynamic generation. 它擅长动态生成。

PDF Make is my favourite JavaScript library for generating PDFs. PDF Make是我最喜欢的用于生成PDF的JavaScript库。

Note: I would attach the files to this post, but there is currently no facility for this in StackOverflow. 注意:我会将文件附加到此帖子,但StackOverflow中目前没有此功能。

  1. react-pdf (published 16 days ago - not tested) react-pdf(16天前发布 - 未经测试)
  2. react-export-excel (published 8 months ago - not tested) react-export-excel(8个月前发布 - 未经测试)
  3. For printing, put window.print() in your code 要进行打印,请将window.print()放在代码中

Example: Copy and paste this as .html (in React, it would be onClick={window.print()} ... If I'm correct) 示例:将其复制并粘贴为.html(在React中,它将是onClick = {window.print()} ...如果我是正确的)

<!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 ) jspdf (见具体问题reactjs
  2. react-excel-workbook 反应-Excel的工作簿
  3. nothing yet, feel free to update the answer if you have. 什么都没有,如果有的话,随时更新答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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