html-docx.js
function ExportQrCode2Word(YearStr,MonthStr,ShiFaSr){//正文图片格式化changeImgToDataurl($("#QrCodeTable"),300,400);var page = '<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="/office//12/omml"= xmlns="/TR/REC-html40"><head>'+'<style><!-- @page{mso-footer: f1;mso-header: h1;}@page Section1{}div.Section1 { page:Section1; }p.MsoHeader,p.MsoFooter { border:0px; text-align:center}table#tableHdFt{margin:0in 0in 0in 900in;width:1px;height:1px;}--></style>'+'<xml><w:WordDocument><w:View>Print</w:View><w:Zoom>100</w:Zoom><w:DoNotOptimizeForBrowser/></w:WordDocument></xml>'+'</head><body><div class=Section1>'//正文内容+ $("#QrCodeTable").html()//页眉页脚设置1px+'<table id=\'tableHdFt\' border=\'0\' cellspacing=\'0\' cellpadding=\'0\'>'+'<tr style=\'\'>'+'<td style=\'height:1pt;width:1px;overflow:hidden;mso-height-rule:exactly;mso-width-rule:exactly;\'>'+'<div style=\'mso-element:footer; text-align:center;position:relative;z-index:-1\' id=f1 >'+'<!--[if supportFields]>'+'<span class=MsoPageNumber>'+'<span style=\'mso-element:field-begin\'></span>PAGE<span style=\'mso-element:field-end\'></span>/<span style=\'mso-element:field-begin\'></span>NUMPAGES</span><span style=\'mso-element:field-end\'></span>'+'</span>'+'<![endif]-->'+'</div>'+'<div style=\'mso-element:header; text-align:center;position:relative;z-index:-1\' id=h1>'+'<span style="text-align:center; font-size:24px; font-weight:bold; font-family:宋体">'+YearStr+'年'+MonthStr+'月份微信汇款<br>合计:'+ShiFaSr+'元</span>'+'</div>' +'</td></tr></table>'+'</div></body>'+'</html>'//转换保存var converted = htmlDocx.asBlob(page);saveAs(converted, YearStr+MonthStr+'WeiXin.docx');}