Hi,
I have a docx document with a table (x columns and x rows) and a text filled only in the first cell.
I want to copy/paste the content of the first cell into the following cells
What is the best approach?
Thx
Franck
Hi,
I have a docx document with a table (x columns and x rows) and a text filled only in the first cell.
I want to copy/paste the content of the first cell into the following cells
What is the best approach?
Thx
Franck
Hi Franck,
Try this:
var document = DocumentModel.Load("input.docx");
var table = (Table)document.GetChildElements(true, ElementType.Table).First();
TableCell firstCell = null;
foreach (var row in table.Rows)
{
foreach (var cell in row.Cells)
{
if (firstCell == null)
firstCell = cell;
else
cell.Blocks.Content.Set(firstCell.Blocks.Content);
}
}
document.Save("output.docx");
Regards,
Mario
It worked perfectly !
Thank you Mario