OpenXml: p elements are required before every tc

Posted: June 24, 2014 in .Net/C#

I received this error when opening a docx created by OpenXml 2.5 SDK.

The error is because that I created a few empty table cell. Paragraph must be created for each table cell in OpenXml.

To fix this is very easy, just create the empty table cell with an empty Paragraph.

TableCell cell = new TableCell(new Paragraph());

PS: Since docx is just a zip container, you can just extract it using any zip program. You will be able to see the document.xml in the word directory. You can compare the malformed xml with a correct one.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s