轻松实现!利用WordExport插件将内容转换为Word文档的教程

随心笔谈11个月前发布 admin
88 0

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>

© 版权声明

相关文章