I am trying to get the cells from 1st column in a table. Getting exception in the "Foreach(Cells c in rng.Tables.Columns.Cells)" because the table contains columns that have mixed cell widths.
for eg: in first row, there are 4 cells and in second row, there are only 2 cells (2 cells merged together)
Error Message: "Cannot access individual columns in this collection because the table has mixed cell widths."
Document oDoc = open word document
foreach (Paragraph p in oDoc.Paragraphs)
Range rng = p.Range;
foreach (Cell c in rng.Tables.Columns.Cells)
Thanks for posting. I am afraid that there is no a good way to work with merged cell. For more information, please see Cindy's post in this thread:
Is there a merged cell between rows? If not, we could iterate each row instead of column. Code like this,
If you have any concern on this post, just feel free to follow up. Have a nice day.
Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.
Would you like to participate?