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="http://schemas.microsoft.com/office/2004/12/omml"= xmlns="http://www.w3.org/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 i
HTML到DOCX转换与页眉页脚设置

这是一个JavaScript函数,用于将包含二维码的HTML内容转换为DOCX文件,并设置页眉和页脚,包括页码和自定义文本。转换过程中,它首先将图片转换为dataURL,然后构建符合Word文档格式的HTML字符串,最后生成并保存为DOCX文件。页眉显示年月和总计金额,页脚包含页面总数。
最低0.47元/天 解锁文章
2050





