I have word document in that copy the table title and Place table title in first row of table, with no top, right, or left border lines
kindly find the below input and expected output file.
Input_word_Document.docx (14.5 KB)
Expected_output_words _Documnet.docx (12.7 KB)
@Yuvarajshivananjappa
Please consider the following code
Document doc = new Document("input.docx");
Table table = doc.FirstSection.Body.Tables[0];
Paragraph para = doc.FirstSection.Body.FirstParagraph;
CellCollection firstCells = table.Rows[0].Cells;
CellCollection secondCells = table.Rows[1].Cells;
for (int i = 4; i >= 0; i--)
{
secondCells[i].FirstParagraph.Remove();
secondCells[i].AppendChild(firstCells[i].FirstParagraph);
firstCells[i].CellFormat.HorizontalMerge = i > 0 ? CellMerge.Previous : CellMerge.First;
}
table.FirstRow.FirstCell.AppendChild(para);
doc.Save("output.docx");
Your given code is working only for single table but in my document is contains multiple table. Each table having different number of rows and columns kindly help me asap.
Please find the below attachment.
Note: I want generalized code.
Input_word_Document.docx (16.3 KB)
Expected_output_words _Documnet.docx (14.2 KB)
Kindly update asap.