2017-02-23 3 views
2

enter image description hereExport-Tabelle zu MS-Word

function export2Word() { 

    var html, link, blob, url, css; 

    css = (
       '<style> table { border-collapse: collapse; border-style:none; } .tables td,th{border:1px solid black;}' + 
       //'@page WordSection1{size: 841.95pt 595.35pt;mso-page-orientation: landscape;}' + 
       //'div.WordSection1 {page: WordSection1;} ' + 
       '</style>' 
      ); 

    html = document.getElementById("tblPrint").outerHTML; 
    blob = new Blob(['\ufeff', css + html], { 
       type: 'application/msword' 
      }); 
    url = URL.createObjectURL(blob); 
    link = document.createElement('A'); 
    link.href = url; 
    link.download = 'Document'; // default name without extension 
    document.body.appendChild(link); 
    if (navigator.msSaveOrOpenBlob) 
     navigator.msSaveOrOpenBlob(blob, 'Document.doc'); // IE10-11 
    else link.click(); // other browsers 
     document.body.removeChild(link); 
}; 

Ich möchte Tabelle zu MS-Word exportieren, als ich versuchte dann keine Tabellenstruktur zeigt nur Daten

zeigt und ich Seitenumbruch für neue rollno Verwendung wie <div style="page-break-after:always;">&nbsp;&nbsp;&nbsp;&nbsp;</div> funktioniert das auch nicht

Was ist falsch in meinem Code? und was zu tun für Seitenumbruch in MS-Word?

Vielen Dank im Voraus

Antwort

1

bitte versuchen Sie es dieses

export html table as word file

oder

var docDOM = document.getElementById('example'); 

var docObject = docx.export(docDOM, // required DOM Object 
{ 
creator: "Creator", // optional String 
lastModifiedBy: "Last person to modify", // optional String 
created: new Date(), // optional Date Object 
modified: new Date() // optional Date Object 
}); 

var link = document.createElement('a'); 
link.appendChild(document.createTextNode("Download Link Text")); 
link.title = "Download Title"; 
link.download = "FilenameHere.docx"; 
link.href = docObject.href(); 
document.getElementById("example").appendChild(link); 

convert html table to word

+0

Ich habe versucht, arbeiten beide es es richtig kein Problem mit dem Export aber Tabelle Struktur zeigt nicht nur Content-Expo rt – Pravin

Verwandte Themen