欢迎光临 - 我的站长站,本站所有资源仅供学习与参考,禁止用于商业用途或从事违法行为!

js教程

利用wordexport插件将内容转换word文档教程

js教程 我的站长站 2022-05-02 共251人阅读

1、首先下载wordexport的js,下载地址:

https://GitHub.com/eligrey/FileSaver.js/

https://github.com/markswindoll/jQuery-Word-Export

2、然后在需要转换的页面引入jquery 和FileSaver.js

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/FileSaver.js"></script>
<script type="text/javascript" src="js/jquery.wordexport.js"></script>

3、在需要转换的内容的DIV上加上ID

<div id="export-content">Your content here</div>

4、创建一个导出的按钮例如:

<a class="btn jquery-word-export" href="javascript:void(0)">导出为.doc文档</a>

5、最后加上事件js代码

<script type="text/javascript">
jQuery(document).ready(function($) {
    $("a.jquery-word-export").click(function(event) {
        $("#pagecontent").wordExport();
    });
});
</script>