创建(导出)使用ReactJS造型良好的Word文档

发布于 2025-02-09 10:24:42 字数 327 浏览 1 评论 0原文

我正在寻找一种使用ReactJ创建良好型Word文档的方法。

更多信息。

我在A4纸的大小完全相同的情况下设计了一个布局。用户可以将信息输入到该布局中。输入所有必需的信息后。我需要提供一种将当前布局导出到MS Word(.doc或.docx)文档中的方法。 我已经附加了一个图像(从互联网拍摄),以显示我在React中创建的布局。我需要在Word文档中使用完全相同的样式。

示例布局

希望解决方案,谢谢。

I'm looking for a method to create well styled word document using ReactJs.

More information.

I've designed a layout in the exact same size of an A4 sheet. There are input boxes that users can input the information to that layout. after entering all the required information. I need to provide a method to export the current layout in to a Ms Word (.doc or .docx) document.
I've attached an image (taken from the internet) to show what kind of layout that I'm creating in React. I need the same to be in the word document with exactly the same styles.

Example Layout

Hoping a solution, thank you. ????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小ぇ时光︴ 2025-02-16 10:24:42

我最近遇到了同样的问题,并总结了我在堆栈溢出中的方法答案

简而言之,利用“单文件网页”格式,以便在Microsoft Word打开下载的文件时会反映CSS样式。

我在答案中显示的代码仅适用于仅文本,并且无法处理较新的CSS功能,例如网格和Flex。

似乎可以进行一些调整,以便还可以正确包含图像并正确地进行样式(请参阅 demo 在这里),但我自己没有尝试过。

I recently had the same issue and summarised my approach in ths Stack Overflow answer.

In short, take advantage of the "Single File Web Page" format, so that the CSS styles are reflected when you open the downloaded file in Microsoft Word.

The code I show in the answer only works for text-only, and cannot handle newer CSS features such as grid and flex.

It seems possible to make some tweaks so that images are also included and styled correctly (see the demo here), but I haven't tried that myself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文