Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figuring out NestedTables #244

Closed
ChrisBellBO opened this issue Aug 28, 2024 · 6 comments
Closed

Figuring out NestedTables #244

ChrisBellBO opened this issue Aug 28, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@ChrisBellBO
Copy link
Contributor

Hi
I'm trying to figure out how nested tables work. I have a Word document with a table containing two nested tables. I can see WordTable has a NestedTables property which contains the two tables but I can't find a way to get the parent cell for each nested table, am I missing something?

@PrzemyslawKlys
Copy link
Member

I am not sure I understand your question. Each Table has Cells/Rows and so on. Same with nested tables?

@PrzemyslawKlys
Copy link
Member

Oh, i get it. You want to know which cell has nested table. Hrmms

@ChrisBellBO
Copy link
Contributor Author

Yes, that's it

@PrzemyslawKlys
Copy link
Member

PrzemyslawKlys commented Aug 28, 2024

I guess you would need add new property in Cell to include something. This is in the Table itself

        public bool HasNestedTables {
            get {
                foreach (var cell in this.Cells) {
                    var list = cell._tableCell.Descendants<Table>().ToList();
                    if (list.Count > 0) {
                        return true;
                    }
                }
                return false;
            }
        }
        public List<WordTable> NestedTables {
            get {
                var listReturn = new List<WordTable>();
                foreach (var cell in this.Cells) {
                    var list = cell._tableCell.Descendants<Table>().ToList();
                    foreach (var table in list) {
                        listReturn.Add(new WordTable(this._document, table));
                    }
                }
                return listReturn;
            }
        }

So as part of specific Cell, just adjust the logic to it can be per Cell as well.

@ChrisBellBO
Copy link
Contributor Author

Looks good, I will give it a go, thanks

@PrzemyslawKlys PrzemyslawKlys added the enhancement New feature or request label Sep 19, 2024
@PrzemyslawKlys
Copy link
Member

Solved by: #240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants