Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Oct 04, 2023 9:36 pm

I am using a foreach loop to loop through a C# list and create a bulleted list. In the Word document there is always an extra/empty bullet at the end of the list. please advise. Code below

Code: Select all
 @if  //Create a bullet list style
            ListStyle listStyle = new ListStyle(doc, ListType.Bulleted);
            listStyle.Name = "loe1List";
            listStyle.Levels[0].BulletCharacter = "\x00B7";
            listStyle.Levels[0].CharacterFormat.FontName = "Symbol";
            listStyle.Levels[0].TextPosition = 20;
            doc.ListStyles.Add(listStyle);
           

            foreach (LoeSection loeSection in model.LoeSection1)
            {
                //Add a paragraph
                Paragraph titleParagraph = warSection.AddParagraph();
                titleParagraph.AppendText(loeSection.Classification + " " + loeSection.ShortTitle);
                titleParagraph.Format.AfterSpacing = 5f;

                foreach (Update update in loeSection.Updates)
                {
                    //Add a paragraph and apply the numbered list style to it
                    titleParagraph = warSection.AddParagraph();
                    titleParagraph.AppendText(update.UpdateClass + " " + update.UpdateQText);
                    titleParagraph.ListFormat.ApplyStyle("loe1List");
                    titleParagraph.ListFormat.ListLevelNumber = 0;
                }

                foreach (RCCCWAR.Models.Background background in loeSection.Backgrounds)
                {
                    //Add a paragraph and apply the numbered list style to it                   
                    titleParagraph.AppendText(background.BackgroundClass + " " + background.BackgroundQText);
                    titleParagraph.ListFormat.ApplyStyle("loe1List");
                    titleParagraph.ListFormat.ListLevelNumber = 0;
                }

            }

aebrey84
 
Posts: 5
Joined: Mon Aug 08, 2022 5:47 pm

Fri Oct 06, 2023 1:50 am

Hi,

Thank you for bringing the issue to our attention.

As a first step, I have conducted a simple test to replicate the issue you have reported. However, I was unable to reproduce the problem. Could you please provide me with the complete code and testing documents that you used during your evaluation? These documents would help me better understand the specifics of your test setup and conditions. Additionally, if possible, please provide me with any results documents that show the observed behavior. These documents will assist me in analyzing the problem and identifying potential solutions.

I look forward to receiving your response and working together to resolve this issue. If you have any further questions or require further assistance, please do not hesitate to contact me.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.Doc