I have the above code for creating the table using interop c#. while calling the same function "FillWordPaPer" ,it gives the error " Cannot access individual columns in this collection because the table has mixed cell widths"
public void FillWordPaPer(List<DTO> DTOList, CustomMainDTO DTO,
Document document, int level
{
int currentSubLevel = level
if (currentSubLevel > 0)
{
if (!string.IsNullOrEmpty(DTO.Description))
{
int appendingIndex = 0;
string appendingtext = string.Empty;
for (int i = 0; i < currentSubLevel; i++)
{
appendingtext = appendingtext + "\r\n";
}
object oEndOfDoc1 = "\\endofdoc";
Microsoft.Office.Interop.Word.Table testTable;
Microsoft.Office.Interop.Word.Range wrdRng1 = document.Bookmarks.get_Item(ref oEndOfDoc1).Range;
testTable = document.Tables.Add(wrdRng1, 1, 2, ref missing, ref missing);
testTable.Columns[1].SetWidth(20, WdRulerStyle.wdAdjustSameWidth);
testTable.Columns[2].SetWidth(400, WdRulerStyle.wdAdjustSameWidth);
testTable.Cell(1, 1).Range.Text = appendingtext;
testTable.Cell(1, 2).Range.Text =DTO.Title;
}
}
var subData = nDTOList.Where(q => q.ParentID == DTO.ID);
sublevel++;
foreach (var item in subData )
{
if (!insertedIds.Any(x => x == item.ID))
{
insertedIds.Add(item.ID);
FillWordPaPer(DTOList, item, document, sublevel);
}
}
}