Answers for "export html to word javascript"

0

export html to word javascript

function exportHTML(Element) {
    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>Anasbehhari title</title></head><body>";
    var footer = "</body></html>";
    var sourceHTML = header + document.getElementById(Element).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 = 'filename.doc';
    fileDownload.click();
    document.body.removeChild(fileDownload);
}
Posted by: Guest on April-22-2021
0

export html to word javascript

function exportHTML(Element) {
    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>Anasbehhari title</title></head><body>";
    var footer = "</body></html>";
    var sourceHTML = header + document.getElementById(Element).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 = 'filename.doc';
    fileDownload.click();
    document.body.removeChild(fileDownload);
}
Posted by: Guest on April-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language