I create a word document using DocX project.
I need to insert table into my doc , but I don't know what should I do?
string fileName = @"D:\Users\John\Documents\DocXExample.docx";
// Create a document in memory:
var doc = DocX.Create(fileName);
// Insert a paragrpah:
//doc.InsertParagraph("This is my first paragraph");
// Save to the output directory:
doc.Save();
// Open in Word:
Process.Start("WINWORD.EXE", fileName);
The sample code :
Table t = document.AddTable(20,2);
t.Rows[0].Cells[0].Paragraphs.First().Append("value1");
t.Rows[1].Cells[0].Paragraphs.First().Append("value2");
t.Rows[2].Cells[0].Paragraphs.First().Append("value3");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.