EvotecIT / OfficeIMO

Fast and easy to use cross-platform .NET library that creates or modifies Microsoft Word (DocX) and later also Excel (XLSX) files without installing any software. Library is based on Open XML SDK
MIT License
279 stars 49 forks source link

Add support for Tabs #128

Closed PrzemyslawKlys closed 1 year ago

PrzemyslawKlys commented 1 year ago

This PR solves:

Add ability to add tabs to the document.

public static void Example_BasicWordWithTabs(string folderPath, bool openWord) {
    Console.WriteLine("[*] Creating standard document with tabs");
    string filePath = System.IO.Path.Combine(folderPath, "BasicWordWithTabs.docx");
    using (WordDocument document = WordDocument.Create(filePath)) {
        var paragraph1 = document.AddParagraph("To jest po polsku").AddTab().AddTab().AddText("Test");

        Console.WriteLine(document.Paragraphs.Count);

        Console.WriteLine(document.Paragraphs[1].IsTabChar);
        Console.WriteLine(document.Paragraphs[2].IsTabChar);

        Console.WriteLine(paragraph1.IsTabChar);

        var paragraph2 = document.AddParagraph("Adding paragraph1 with some text and pressing ENTER").AddTab();

        Console.WriteLine(document.Paragraphs.Count);

        Console.WriteLine(paragraph2.IsTabChar);

        paragraph2.TabChar.Remove();
        document.Save(openWord);
    }
}