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
280 stars 50 forks source link

List style is not saved when saving to stream #61

Closed rstm-sf closed 1 year ago

rstm-sf commented 1 year ago
internal static void Example_BasicLists_Save_To_Stream(string folderPath, bool openWord) {
    using var document = WordDocument.Create();
    foreach (var listStyle in (WordListStyle[])Enum.GetValues(typeof(WordListStyle))) {
        var paragraph = document.AddParagraph(listStyle.ToString());
        paragraph.SetColor(Color.Red).SetBold();
        paragraph.ParagraphAlignment = JustificationValues.Center;

        var wordList1 = document.AddList(listStyle);
        wordList1.AddItem("Text 1", 0);
        wordList1.AddItem("Text 2", 1);
        wordList1.AddItem("Text 3", 2);
        wordList1.AddItem("Text 4", 3);
        wordList1.AddItem("Text 5", 4);
        wordList1.AddItem("Text 6", 5);
        wordList1.AddItem("Text 7", 6);
        wordList1.AddItem("Text 8", 7);
        wordList1.AddItem("Text 9", 8);
    }

    using var outputStream = new MemoryStream();
    document.Save(outputStream);

    var filePath = Path.Combine(folderPath, "Document with Lists when save to stream.docx");
    File.WriteAllBytes(filePath, outputStream.ToArray());
    if (openWord) {
        Helpers.Open(filePath, openWord);
    }
}

image

PrzemyslawKlys commented 1 year ago

Any guess why and how to fix it?