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

Add ability to add nested tables (add table into cell of an existing table) #35

Merged
merged 10 commits into from
Oct 9, 2022

Conversation

PrzemyslawKlys
Copy link
Member

@PrzemyslawKlys PrzemyslawKlys commented Aug 22, 2022

  • Adds ability to add nested table into existing table.
internal static void Example_NestedTables(string folderPath, bool openWord) {
    Console.WriteLine("[*] Creating standard document with nested tables");
    string filePath = System.IO.Path.Combine(folderPath, "Document with Nested Tables.docx");
    using (WordDocument document = WordDocument.Create(filePath)) {
        var paragraph = document.AddParagraph("Lets add table ");
        paragraph.ParagraphAlignment = JustificationValues.Center;
        paragraph.Bold = true;
        paragraph.Underline = UnderlineValues.DotDash;

        WordTable wordTable = document.AddTable(4, 4, WordTableStyle.GridTable1LightAccent1);
        wordTable.Rows[0].Cells[0].Paragraphs[0].Text = "Test 1";
        wordTable.Rows[1].Cells[0].Paragraphs[0].Text = "Test 2";
        wordTable.Rows[2].Cells[0].Paragraphs[0].Text = "Test 3";
        wordTable.Rows[3].Cells[0].Paragraphs[0].Text = "Test 4";

        wordTable.Rows[0].Cells[0].AddTable(3, 2, WordTableStyle.GridTable2Accent2);

        wordTable.Rows[0].Cells[1].AddTable(3, 2, WordTableStyle.GridTable2Accent5, true);

        document.Save(openWord);
    }
}
  • Adds NestedTables property for WordTable to get all nested tables for given table
  • Adds HasNestedTables property for WordTable to know if table has nested tables
  • Adds IsNestedTable property for WordTable to know if table is nested table
  • Adds ParentTable property for WordTable to find parent table if the table is nested
  • Added some summaries to multiple table related methods/properties
  • Adds TablesIncludingNestedTables property to Sections and Document to make it easy to find all tables within document and manipulate them

@tobi-coder
Copy link

Thank you very much! I'll test ist in my scripts.

@PrzemyslawKlys PrzemyslawKlys merged commit e072c3b into master Oct 9, 2022
@PrzemyslawKlys PrzemyslawKlys deleted the NestedTables branch October 11, 2022 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants