遍历有单元格合并的表格需要判断单元格的length是否为-1,为-1说明该单元格被合并了:
- for (int row = 1; row <= textControl1.Tables.GetItem().Rows.Count; row++)
- {
- for (int col = 1; col <= textControl1.Tables.GetItem().Columns.Count; col++)
- {
- if (textControl1.Tables.GetItem().Cells.GetItem(row,col).Length != -1)
- {
- textControl1.Tables.GetItem().Cells.GetItem(row, col).Text = String.Format("({0},{1})",row,col);
- }
- }
- }
复制代码
同时可以通过以上属性来判断当前表格的嵌套关系:NestedLevel、NestedTables、OuterMostTable、OuterTable |