close messageThis website uses 'cookies', both our own as well as from third parties, to provide a better experience and service. When browsing our website or using our services you agree to our use of 'cookies'. For more information, see our Privacy policy.

importListStyle

importListStyle

BASIC / ADVANCED / PREMIUM

Imports an existing list style from an external Word document.

Description
public void importListStyle(String source, String id, String name) throws Exception

This method allows to import a list style from an external Word document.

Parameters

path

The path to the Word document from which we want to import the list style.

id

The id of the style to be imported.

name

New style name.

Return values

Void.

Code samples

Example #1

x
 
1
package examples.LayoutAndGeneral.importListStyle;
2
3
import java.util.ArrayList;
4
5
import com.javadocx.CreateDocx;
6
7
public class Sample1 {
8
    public static void main(String[] args) throws Exception {
9
        CreateDocx docx = new CreateDocx();
10
11
        // import custom list styles
12
        docx.importListStyle("src/examples/files/TemplateStyleList.docx", "1", "myliststyle");
13
14
        // add a list using an imported numbering style
15
        ArrayList<String> itemList = new ArrayList<String>();
16
        itemList.add("Line 1");
17
        itemList.add("Line 2");
18
        itemList.add("Line 3");
19
        itemList.add("Line 4");
20
        itemList.add("Line 5");
21
22
        docx.addList(itemList, "myliststyle");
23
24
        docx.createDocx("example_importListStyle_1");
25
    }
26
}
27
­
­