简体   繁体   中英

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. 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).

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. 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. Couldn't you provide a .pdf / .csv instead? There are some popular libraries and it's a lot easier to implement. You can do it directly in the FrontEnd.

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