Ich habe das htmtdocx mal getestet. Es läuft zwar ohne Fehlerausgaben durch, aber das Dokument ist leer. Dieses Problem wird hier diskutiert:
https://github.com/evidenceprime/html-docx-js/issues/19
und der Grund ist offenbar, dass OpenOffice, GoogleDocs etc. die Altchunk-Technologie unterstützen. Selber habe ich Softmaker-Office und dafür könnte das auch gelten. Sicher hast Du MS-Office, dann probiere doch Mal, ob es damit funktioniert.
HTML
<!doctype html>
<html lang="en">
<head>
<title>Test download</title>
<meta charset="utf-8">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="html-docx-js-master/dist/html-docx.js"></script>
<script src="js/download.js"></script>
</head>
<body>
<table id="table">
</table>
<button onclick="save();">Speichern</button>
<script>
document.getElementById("table").innerHTML = "<tr><td>Zelle 1</td><td>Zelle 2</td></tr>";
function save() {
var thehtml = $("html");
thehtml.find("script").remove();
thehtml.find("button").remove();
doc = '<!doctype html><html>' + thehtml.html() + '</html>';
var converted = htmlDocx.asBlob(doc, {orientation: 'portrait'});
download(converted, "specification.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
}
</script>
</body>
</html>
Alles anzeigen