简体   繁体   English

如何使用 React js 将 HTML 导出到 Word 文档

[英]How to Export HTML to Word Document with React js

Hello I have HTML data in my React App and want to export this in word document and download at button click event.您好,我的 React App 中有 HTML 数据,我想将其导出到 word 文档中并在按钮单击事件中下载。 can any one help to make this one please.任何人都可以帮忙制作这个吗?

          let element = (
            <p  style={{fontSize: "10px", color:"#000"}}>
              Your investment in the maintenance package is just , billed directly to your credit card.
            </p>
           )

Need function to export this in.docx document需要function才能导出这个in.docx文件

By clicking this button, the exportHTML() JavaScript function will be called.通过单击此按钮,将调用 exportHTML() JavaScript function。 The HTML portion to be exported into a word document will be identified with the ID selector.要导出到word文档中的HTML部分将用ID选择器标识。 The content of the DIV element specified with the id source-html is used to build the source of the HTML export in the JavaScript function.使用 id source-html 指定的 DIV 元素的内容用于在 JavaScript function 中构建 HTML 导出的源。

By clicking this button, the exportHTML() JavaScript function will be called.通过单击此按钮,将调用 exportHTML() JavaScript function。 The HTML portion to be exported into a word document will be identified with the ID selector.要导出到word文档中的HTML部分将用ID选择器标识。 The content of the DIV element specified with the id source-html is used to build the source of the HTML export in the JavaScript function.使用 id source-html 指定的 DIV 元素的内容用于在 JavaScript function 中构建 HTML 导出的源。

You can try using the Open XML SDK if you need to build Word documents on the fly.如果您需要即时构建 Word 文档,可以尝试使用 Open XML SDK。 You may search for any libraries in JavaScript that allows creating Word documents like you could do using that SDK, see https://openxmldeveloper.org/ .您可以在 JavaScript 中搜索任何允许像使用 SDK 那样创建 Word 文档的库,请参阅https://openxmldeveloper.org/ For example, you may find the Creating OpenXML documents using JavaScript post helpful.例如,您可能会发现使用 JavaScript 创建 OpenXML 文档的帖子很有帮助。

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

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