简体   繁体   English

docx文件生成并在reactjs应用中下载

[英]docx file generation and download in reactjs app

I have been told to adapt a react frontend with a firebase backend and hosting to be able to generate docx or xlsx files from cart-like information, much like a receipt. 有人告诉我,将React前端与Firebase后端和托管进行适配,以便能够从类似购物车的信息(类似于收据)生成docx或xlsx文件。 The user has to be able to download such generated file and that file doesn't need to persist after the user has generated and downloaded it. 用户必须能够下载此类生成的文件,并且在用户生成并下载该文件后,该文件无需保留。 The docx or xlsx file needs to follow a certain template, so most probably I will need to style and customize the receipt-like output from the code (borders, margins, etc). docx或xlsx文件需要遵循特定的模板,因此很可能我将需要样式化和自定义代码中类似收据的输出(边界,边距等)。

My current problem is that i am lost and confused on how to approach this: I have found some react libraries that generate docx files ( redocx ), but it seems they generate the file inside the directory where the frontend is hosted, and I do not know how to continue from there. 我当前的问题是我对如何实现此方法感到迷茫和困惑:我发现一些生成docx文件( redocx )的React库,但是似乎它们在托管前端的目录内生成了文件,但我没有知道如何从那里继续。 It also seems that the styling it is able to do is not enough, but this is not as important as being able to generate it and prompt the download. 似乎还不能做的样式,但这还不如能够生成样式并提示下载的重要性。

I have also thought of developing a express or similar backend that manages the file generation because I have been told that in the backend it should be easier to handle it, so this is also a possibility. 我还考虑过开发一个用于管理文件生成的快速或类似后端,因为有人告诉我在后端应该更容易处理它,因此这也是一种可能。

What is the standard way to approach this kind of problem? 解决此类问题的标准方法是什么? Are there any free tools or libraries that help with this? 有免费的工具或库可以帮助您吗?

Thanks! 谢谢!

I'm just aware of https://github.com/open-xml-templating/docxtemplater but it costs money. 我只是知道https://github.com/open-xml-templating/docxtemplater,但要花钱。 Couldn't you provide a .pdf / .csv instead? 您不能提供.pdf / .csv吗? There are some popular libraries and it's a lot easier to implement. 有一些流行的库,并且易于实现。 You can do it directly in the FrontEnd. 您可以直接在FrontEnd中进行操作。

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

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