I have find the reason ,it is the origian docx file contains a table that has no border .How can we avoid this?
following is the code :
- Code: Select all
Document document = new Document();
document.LoadFromFile(file);
string htmlTable = "<sub><table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" style=\"table-layout:fixed;\" xmlns:exsl=\"urn:schemas-microsoft-com:xslt\">" +
"<tbody><tr><td rowspan=\"2\" align=\"left\"><p>100</p></td><td>200</td><td><p>300</p></td></tr>" +
"<tr><td><p>500</p></td><td><p>600</p></td></tr></tbody>" +
"</table></sub>";
Paragraph paragraph = new Paragraph(document);
Section section = document.Sections[0];
section.Paragraphs.Insert(2, paragraph);//
paragraph.AppendHTML(htmlTable);
//Save doc file.
document.SaveToFile("Sample.docx", FileFormat.Docx);
//Launching the MS Word file.
WordDocViewer("Sample.docx");