javascript: Converts HTML documents to DOCX in the browser
Convert Word documents (.docx files) to HTML
https://www.npmjs.com/package/mammoth/v/1.11.0?activeTab=code
https://github.com/mwilliamson/mammoth.js
HTML to DOCX converter
https://github.com/TurboDocx/html-to-docx
https://phppot.com/javascript/how-to-export-html-to-word-document-with-javascript/
https://dev.to/jsstampede/embed-html-into-word-documents-with-docxjs-the-easy-way-2n6a
https://www.convertapi.com/html-to-docx/javascript
https://github.com/ConvertAPI/convertapi-library-js TypeScript
https://www.e-iceblue.com/Tutorials/Doc-JavaScript/React/Convert-HTML-to-Word-with-JavaScript-in-React.html
https://evidenceprime.github.io/html-docx-js/
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>How to Export HTML to Word Document with JavaScript</title>
<style>
body {
width: 550px;
font-family: Arial;
line-height: 25px;
}
#btn-export {
background: #484848;
color: #FFF;
border: #000 1px solid;
padding: 10px 20px;
font-size: 12px;
border-radius: 3px;
}
.content-footer {
text-align: center;
}
.source-html-outer {
border: #d0d0d0 1px solid;
border-radius: 3px;
padding: 10px 20px 20px 20px;
}
</style>
</head>
<body>
<div class="source-html-outer">
<div id="source-html">
<h1>
<center>Artificial Intelligence</center>
</h1>
<h2>Overview</h2>
<p>
Artificial Intelligence(AI) is an emerging technology
demonstrating machine intelligence. The sub studies like <u><i>Neural
Networks</i>, <i>Robatics</i> or <i>Machine Learning</i></u>
are the parts of AI. This technology is expected to be a
prime part of the real world in all levels.
</p>
</div>
<div class="content-footer">
<button id="btn-export" onclick="exportHTML();">Export to word
doc</button>
</div>
</div>
<script>
function exportHTML(){
var header = "<html xmlns:o='urn:schemas-microsoft-com:office:office' "+
"xmlns:w='urn:schemas-microsoft-com:office:word' "+
"xmlns='http://www.w3.org/TR/REC-html40'>"+
"<head><meta charset='utf-8'><title>Export HTML to Word Document with JavaScript</title></head><body>";
var footer = "</body></html>";
var sourceHTML = header+document.getElementById("source-html").innerHTML+footer;
var source = 'data:application/vnd.ms-word;charset=utf-8,' + encodeURIComponent(sourceHTML);
var fileDownload = document.createElement("a");
document.body.appendChild(fileDownload);
fileDownload.href = source;
fileDownload.download = 'document.doc';
fileDownload.click();
document.body.removeChild(fileDownload);
}
</script>
</body>
</html>
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
浙公网安备 33010602011771号