Replace cell with StructuredDocumentTag while maintaining original cell properties

Dear support,

we use the latest version of Asopose Words for .Net.

I want to replace a cell with a content control while maintaining the original cell properties.
I have the following code:

StructuredDocumentTag tag = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Cell);
cellToRemove.ParentNode.InsertBefore(tag, cell);
cellToRemove.Remove();

Now the format of the original cell is obiously gone.

The new StructuredDocumentTag already has a cell inside, so I’m not sure how to proceed. Can I copy the CellFormat from one cell to another?
Or shouldn’t I remove the cell and replace the cell inside the StructuredDocumentTag?

It would be nice if you could give me some sample code.

Thanks!

Hi Ulrich,


Thanks for your inquiry. I think, you should remove all content from Cell and insert SDT inside Cell as a child node. However, could you please attach your input Word document and expected document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. We will then provide you code to achieve the same using Aspose.Words.

Best regards,