本文介绍如何使用spire.doc for java将ascii字符设置为word文档中的列表符号。
import com.spire.doc.document;
import com.spire.doc.fileformat;
import com.spire.doc.section;
import com.spire.doc.documents.liststyle;
import com.spire.doc.documents.listtype;
import com.spire.doc.documents.paragraph;
public class setbulletpoints {
public static void main(string[] args) {
//创建document对象并添加节
document doc = new document();
section section = doc.addsection();
//根据不同的ascii字符创建四种不同的列表样式
liststyle liststyle1 = new liststyle(doc, listtype.bulleted);
liststyle1.getlevels().get(0).setbulletcharacter("\u006e");
liststyle1.getlevels().get(0).getcharacterformat().setfontname("wingdings");
liststyle1.setname("liststyle1");
doc.getliststyles().add(liststyle1);
liststyle liststyle2 = new liststyle(doc, listtype.bulleted);
liststyle2.getlevels().get(0).setbulletcharacter("\u0075");
liststyle2.getlevels().get(0).getcharacterformat().setfontname("wingdings");
liststyle2.setname("liststyle2");
doc.getliststyles().add(liststyle2);
liststyle liststyle3 = new liststyle(doc, listtype.bulleted);
liststyle3.getlevels().get(0).setbulletcharacter("\u00b2");
liststyle3.getlevels().get(0).getcharacterformat().setfontname("wingdings");
liststyle3.setname("liststyle3");
doc.getliststyles().add(liststyle3);
liststyle liststyle4 = new liststyle(doc, listtype.bulleted);
liststyle4 .getlevels().get(0).setbulletcharacter("\u00d8");
liststyle4 .getlevels().get(0).getcharacterformat().setfontname("wingdings");
liststyle4.setname("liststyle4");
doc.getliststyles().add(liststyle4);
//添加四个段落并分别应用列表样式
paragraph p1 = section.getbody().addparagraph();
p1.appendtext("spire.doc for .net");
p1.getlistformat().applystyle(liststyle1.getname());
paragraph p2 = section.getbody().addparagraph();
p2.appendtext("spire.pdf for .net");
p2.getlistformat().applystyle(liststyle2.getname());
paragraph p3 = section.getbody().addparagraph();
p3.appendtext("spire.xls for .net");
p3.getlistformat().applystyle(liststyle3.getname());
paragraph p4= section.getbody().addparagraph();
p4.appendtext("spire.presentation for .net");
p4.getlistformat().applystyle(liststyle4.getname());
//保存到文档
doc.savetofile("output/setbulletcharacter.docx", fileformat.docx);
}
}