Hello,
Thanks for your inquiry.
Please refer to the following code to meet your requirement.
- Code: Select all
Document doc = new Document();
doc.LoadFromFile(@"test.docx");
foreach (Section sec in doc.Sections)
{
foreach (ITable table in sec.Tables)
{
TableRow tableHeader = table.Rows[0];
foreach (TableCell headerCell in tableHeader.Cells)
{
foreach (DocumentObject documentObject in headerCell.ChildObjects)
{
if (documentObject is Paragraph)
{
Paragraph paragraph = documentObject as Paragraph;
if (paragraph.Text.Equals("the specific column name"))
{
table.AddRow();
}
}
}
}
}
}
doc.SaveToFile("result.docx", FileFormat.Docx);
If this is not what you want, please provide your input file and your desired output for further investigation. You can send them to us (
[email protected]) via email, thanks in advance.
Sincerely,
Brian
E-iceblue support team