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.

Tue Apr 23, 2024 8:21 am

Hello!

I need to create list with third level with Cyrillic number
1) First level
- Second level
а) Third level

But in ListPatternType there is not such number type.

Could any one help?

sleepstream
 
Posts: 4
Joined: Tue Nov 08, 2016 12:39 pm

Tue Apr 23, 2024 9:48 am

Hi,

Thanks for your inquiry.
Is the symbol of second level (-) not added successfully?

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Wed Apr 24, 2024 6:43 am

Hello!
Symbol of second level (-) added successfully.

Problems with third level

sleepstream
 
Posts: 4
Joined: Tue Nov 08, 2016 12:39 pm

Wed Apr 24, 2024 7:04 am

Hi,

Thanks for your feedback.
Please refer to the following code to achieve your requirement.

Code: Select all
 // Declare the output file path
        String output="output/lists.docx";

        // Create a new Document object
        Document document = new Document();
       
        // Add a new section to the document
        Section sec = document.addSection();

        // Create a new ListStyle object with numbered list type
        ListStyle numberList = new ListStyle(document, ListType.Numbered);
     
        // Set the name of the list style
        numberList.setName("numberList");
       
        // Set the pattern type and number suffix for the first level of the list
        numberList.getLevels().get(0).setPatternType(ListPatternType.Low_Letter);
        numberList.getLevels().get(0).setNumberSufix(")");

        // Add the numberList to the document's list styles
        document.getListStyles().add(numberList);

        // Add a paragraph to the section
        Paragraph paragraph = sec.addParagraph();
       
        // Add another paragraph to the section
        paragraph = sec.addParagraph();
       
        // Append text to the second paragraph
        paragraph.appendText("List Item 1");
       
        // Apply the numberList style to the second paragraph
        paragraph.getListFormat().applyStyle(numberList.getName());

        // Save the document to the output file in Docx format
        document.saveToFile(output, FileFormat.Docx);


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Doc