I am getting the below exception while reading the merged cell.
"Cannot access individual rows in this collection because the table has vertically merged cells."
My code is,
foreach (Row aRow in doc.Tables[i].Rows)
{
foreach (Cell aCell in aRow.Cells)
{
MessageBox.Show(aCell.Range.Text);
}
}
// My table format is..
| R1C1 |R1C2|______|
| R2C1 |R2C2| R*C3 ..|
| R3C1 |R3C2|______|
You could try the following:
Table table = Globals.ThisDocument.Tables[1];
Range range = table.Range;
for (int i = 1; i <= range.Cells.Count; i++)
{
if(range.Cells[i].RowIndex == table.Rows.Count)
{
range.Cells[i].Range.Text = range.Cells[i].RowIndex + ":" + range.Cells[i].ColumnIndex;
MessageBox.Show(range.Cells[i].Range.Text);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With