Skip to content

Commit 5d3cb06

Browse files
authored
Resolve comments
1 parent c30cbfc commit 5d3cb06

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

knowledge-base/radwordsprocessing-find-table-by-bookmark.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: This article demonstrates how to identify and retrieve the table th
44
type: how-to
55
page_title: How to Retrieve a Table by Bookmark in RadWordsProcessing
66
slug: radwordsprocessing-find-table-by-bookmark
7-
tags: radwordsprocessing, document processing, bookmarks, table, nested tables
7+
tags: radwordsprocessing, document, processing, bookmarks, table, nested, tables
88
res_type: kb
99
ticketid: 1657970
1010
---
@@ -17,7 +17,7 @@ ticketid: 1657970
1717

1818
## Description
1919

20-
When working with documents, it's common to need to find a table that contains a specific bookmark. This can become complex when dealing with nested tables, as a bookmark could be situated within multiple layers of tables. This KB article outlines methods to find either the innermost or outermost table containing a given bookmark, catering to scenarios involving nested tables.
20+
When working with documents, it's a common requirement to find a table that contains a specific bookmark. This can become complex when dealing with nested tables, as a bookmark could be situated within multiple layers of tables. This KB article outlines methods to find either the innermost or outermost table containing a given bookmark, catering to scenarios involving nested tables.
2121

2222
This KB article also answers the following questions:
2323
- How can I find a table containing a specific bookmark in a document?
@@ -26,9 +26,13 @@ This KB article also answers the following questions:
2626

2727
## Solution
2828

29-
To find a table containing a specific bookmark, especially in documents with nested tables, you can use the following two methods: `GetInnermostTableContainingBookmark` and `GetOutermostTableContainingBookmark`. These methods help in identifying either the innermost or outermost table that contains the bookmark, depending on the nesting level of tables in the document.
29+
To find a table containing a specific bookmark, especially in documents with nested tables, you can use the following custom methods: `GetInnermostTableContainingBookmark` and `GetOutermostTableContainingBookmark`. These methods help in identifying either the innermost or outermost table that contains the bookmark, depending on the nesting level of tables in the document.
3030

3131
1. **Load the document and identify the bookmark:**
32+
2. **Define methods to get the innermost and outermost tables containing the bookmark:**
33+
- **GetInnermostTableContainingBookmark:**
34+
- **GetOutermostTableContainingBookmark:**
35+
3. **Retrieve the innermost and outermost tables containing the bookmark (as needed):**
3236

3337
```csharp
3438
RadFlowDocument document;
@@ -40,13 +44,10 @@ using (Stream input = File.OpenRead("input.docx"))
4044
}
4145

4246
Bookmark bookmark = document.EnumerateChildrenOfType<BookmarkRangeStart>().Select(b => b.Bookmark).ToList().First(bm => bm.Name == "BookmarkName");
43-
```
4447

45-
2. **Define methods to get the innermost and outermost tables containing the bookmark:**
46-
47-
- **GetInnermostTableContainingBookmark:**
48+
Table innermostTable = GetInnermostTableContainingBookmark(bookmark);
49+
Table outermostTable = GetOutermostTableContainingBookmark(bookmark);
4850

49-
```csharp
5051
private static Table GetInnermostTableContainingBookmark(Bookmark bookmark)
5152
{
5253
TableCell tableCell = bookmark.BookmarkRangeStart.Paragraph.BlockContainer as TableCell;
@@ -58,11 +59,7 @@ private static Table GetInnermostTableContainingBookmark(Bookmark bookmark)
5859

5960
return null;
6061
}
61-
```
62-
63-
- **GetOutermostTableContainingBookmark:**
6462

65-
```csharp
6663
private static Table GetOutermostTableContainingBookmark(Bookmark bookmark)
6764
{
6865
TableCell tableCell = bookmark.BookmarkRangeStart.Paragraph.BlockContainer as TableCell;
@@ -89,13 +86,6 @@ private static Table GetTableContainingAnotherTable(Table table)
8986
}
9087
```
9188

92-
3. **Retrieve the innermost and outermost tables containing the bookmark (as needed):**
93-
94-
```csharp
95-
Table innermostTable = GetInnermostTableContainingBookmark(bookmark);
96-
Table outermostTable = GetOutermostTableContainingBookmark(bookmark);
97-
```
98-
9989
If the bookmark is in a single table, both methods will yield the same result. These methods ensure you can accurately find the table containing a specific bookmark, regardless of the complexity of the document's table structure.
10090

10191
## See Also

0 commit comments

Comments
 (0)