Aspose.Words for Java是否可以为段落添加编号或者项目符号?

否可以为段落添加编号或者项目符号?即生成word中的如下内容:1.png (15.4 KB)
2.png (6.2 KB)



Document doc = new Document();

// Create a new list style.
// List formatting associated with this list style is default numbered.
Style listStyle = doc.getStyles().add(StyleType.LIST, "MyListStyle");

// This list defines the formatting of the list style.
// Note this list can not be used directly to apply formatting to paragraphs (see below).
com.aspose.words.List list1 = listStyle.getList();

// Check some basic rules about the list that defines a list style.
System.out.println("IsListStyleDefinition: " + list1.isListStyleDefinition()); // Will be true
System.out.println("IsListStyleReference: " + list1.isListStyleReference()); // Will be false
System.out.println("IsMultiLevel: " + list1.isMultiLevel()); // Will be true
System.out.println("List style has been set: " + (listStyle == list1.getStyle())); // Are equal

// Modify formatting of the list style to our liking.
for (int i = 0; i < list1.getListLevels().getCount(); i++)
    ListLevel level = list1.getListLevels().get(i);

// Add some text to our document and use the list style.
DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln("Using list style first time:");

// This creates a list based on the list style.
com.aspose.words.List list2 = doc.getLists().add(listStyle);

// Check some basic rules about the list that references a list style.
System.out.println("IsListStyleDefinition: " + list2.isListStyleDefinition()); // Will be false
System.out.println("IsListStyleReference: " + list2.isListStyleReference()); // Will be true
System.out.println("List Style has been set: " + (listStyle == list2.getStyle())); // Are equal

// Apply the list that references the list style.
builder.writeln("Item 1");
builder.writeln("Item 2");

builder.writeln("Using list style second time:");

// Create and apply another list based on the list style.
com.aspose.words.List list3 = doc.getLists().add(listStyle);
builder.writeln("Item 1");
builder.writeln("Item 2");