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 Remove & Merge Lists #207

Merged
merged 9 commits into from Feb 20, 2024
Merged

Add Remove & Merge Lists #207

merged 9 commits into from Feb 20, 2024

Conversation

PrzemyslawKlys
Copy link
Member

@PrzemyslawKlys PrzemyslawKlys commented Feb 18, 2024

This PR resolves issue:

This PR adds:

  • Merging document.Lists[0].Merge(document.Lists[1]);
  • Removal document.Lists[0].Remove();

How to use:

internal static void Example_BasicLists3(string folderPath, bool openWord) {
    string filePath = System.IO.Path.Combine(folderPath, "Document with Lists3.docx");
    using (WordDocument document = WordDocument.Create(filePath)) {
        var paragraph = document.AddParagraph("This is 1st list");
        paragraph.ParagraphAlignment = JustificationValues.Center;

        WordList wordList1 = document.AddList(WordListStyle.Headings111);
        wordList1.AddItem("Text 1 - List1");
        wordList1.AddItem("Text 2 - List1", 1);
        wordList1.AddItem("Text 3 - List1", 2);

        paragraph = document.AddParagraph("This is 2nd list");
        paragraph.ParagraphAlignment = JustificationValues.Center;

        WordList wordList2 = document.AddList(WordListStyle.Headings111);
        wordList2.AddItem("Text 1");
        wordList2.AddItem("Text 2", 1);
        wordList2.AddItem("Text 3", 2);

        paragraph = document.AddParagraph("This is 3rd list").SetColor(Color.DeepPink).SetUnderline(UnderlineValues.Double);
        paragraph.ParagraphAlignment = JustificationValues.Center;

        WordList wordList3 = document.AddList(WordListStyle.Bulleted);
        wordList3.AddItem("Text 7.1", 1);
        wordList3.AddItem("Text 7.2", 2);
        wordList3.AddItem("Text 7.3", 2);
        wordList3.AddItem("Text 7.4", 0);
        wordList3.AddItem("Text 7.5", 0);
        wordList3.AddItem("Text 7.6", 1);
        wordList3.AddItem("Text 7");

        paragraph = document.AddParagraph("This is 4th list").SetColor(Color.Aqua).SetUnderline(UnderlineValues.Double);
        paragraph.ParagraphAlignment = JustificationValues.Center;

        WordList wordList4 = document.AddList(WordListStyle.Bulleted);
        wordList4.AddItem("Text 8");
        wordList4.AddItem("Text 8.1", 1);
        wordList4.AddItem("Text 8.2", 2);
        wordList4.AddItem("Text 8.3", 2);
        wordList4.AddItem("Text 8.4", 0);
        wordList4.AddItem("Text 8.5", 0);
        wordList4.AddItem("Text 8.6", 1);

        Console.WriteLine("List count: " + document.Lists.Count); // "List count: 4

        document.Lists[0].Remove();

        Console.WriteLine("List count: " + document.Lists.Count); // "List count: 3

        document.Lists[0].Merge(document.Lists[1]);

        Console.WriteLine("List count: " + document.Lists.Count); // "List count: 2

        document.Save(openWord);
    }
}

@PrzemyslawKlys PrzemyslawKlys added the enhancement New feature or request label Feb 18, 2024
@PrzemyslawKlys PrzemyslawKlys linked an issue Feb 18, 2024 that may be closed by this pull request
@PrzemyslawKlys PrzemyslawKlys marked this pull request as ready for review February 18, 2024 17:52
@PrzemyslawKlys PrzemyslawKlys merged commit 5f16f4f into master Feb 20, 2024
3 checks passed
@PrzemyslawKlys PrzemyslawKlys deleted the AddMergeRemoveLists branch February 20, 2024 19:39
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

Successfully merging this pull request may close these issues.

Add ability to merge & remove lists
1 participant