I am using:
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>";
//@ts-ignore
if(ev.target.id === "screenword"){
this.setState({
typeOfPrint: "screenword",
}, () => {
var sourceHTML1 = header+document.getElementById("spage").innerHTML+footer;
var source1 = 'data:application/vnd.ms-word;charset=utf-8,' + encodeURIComponent(sourceHTML1);
var fileDownload1 = document.createElement("a");
document.body.appendChild(fileDownload1);
fileDownload1.href = source1;
fileDownload1.download = this.state.PPName+'.doc';
fileDownload1.click();
document.body.removeChild(fileDownload1);
To create a doc file but want to create a docx. I've searched and cannot find any guidance on how to update this code. I'm trying to avoid external libraries as much as possible.